f



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

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
-- 
Posted via http://www.ruby-forum.com/.

0
mmc_collins (124)
12/11/2008 3:50:55 PM
comp.lang.ruby 48886 articles. 0 followers. Post Follow

1 Replies
492 Views

Similar Articles

[PageSpeed] 49

Mmcolli00 Mom wrote:
> 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

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



0
12/12/2008 3:47:03 AM
Reply: