Forum: Ruby rename to txt file - file not found in list,but in directory

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Mmcolli00 M. (Guest)
on 2008-12-11 17:57
I am trying to rename a file in my directory. I can see this file in
directory. It has an extention of .dep, when I attempt to rename it,
nothing gets renamed. When I output all filenames from the directory
this particular file containing .dep is not on the list. I can see it is
there, however this script doesn't pull it. Do you know what this might
mean?

require 'fileutils'
require 'find'
require 'ftools'
require 'enumerator'

#locate new .dep file and rename to txt file for later modification

Dir.entries("C:/Diff").each do |filename|
 if File.extname("*.dep") then
    puts filename
    puts File.ftype("2227_12112008090607519.dep") #<--can't find this
     File.rename(".dep", "orgDep.txt") #<--doesn't find any file with
.dep
    end
   end
end
Reid T. (Guest)
on 2008-12-12 05:54
(Received via mailing list)
Mmcolli00 Mom wrote:
> require 'enumerator'
>    end
> end

require 'fileutils'
require 'find'
require 'ftools'
require 'enumerator'

#locate new .dep file and rename to txt file for later modification

Dir.entries("/tmp").each do |filename|
     if File.extname(filename).match(".dep") then
         puts "#{filename}"
         puts File.ftype("2227_12112008090607519.dep") #<--can't find
this
         File.rename(filename, "orgDep.txt") #<--doesn't find any file
with .dep
     end
end
This topic is locked and can not be replied to.