Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > rename to txt file - file not found in list,but in directory

Reply
Thread Tools

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

 
 
Mmcolli00 Mom
Guest
Posts: n/a
 
      12-11-2008
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/.

 
Reply With Quote
 
 
 
 
Reid Thompson
Guest
Posts: n/a
 
      12-12-2008
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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
counting how often the same word appears in a txt file...But my codeonly prints the last line entry in the txt file dgcosgrave@gmail.com Python 8 12-19-2012 06:29 PM
Diff. between FileWriter("f.txt") and OutputStreamWriter(new FileOutputStream("f.txt")) ? Jochen Brenzlinger Java 7 09-15-2011 01:23 AM
Rename File Using Strring Found in File? He Who Greets With Fire Perl Misc 19 03-07-2008 10:01 PM
System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() are not returning the specified directory Nathan Sokalski ASP .Net 2 09-06-2007 03:58 PM
Opening a txt file to view ( i.e. readme.txt) Sameen C++ 2 08-29-2005 03:14 PM



Advertisments