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

Discussion in 'Ruby' started by Mmcolli00 Mom, Dec 11, 2008.

  1. 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/.
     
    Mmcolli00 Mom, Dec 11, 2008
    #1
    1. Advertising

  2. 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
     
    Reid Thompson, Dec 12, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. William Parker
    Replies:
    1
    Views:
    3,107
    Martin
    Jun 27, 2004
  2. Sameen
    Replies:
    2
    Views:
    459
    Victor Bazarov
    Aug 29, 2005
  3. shapper
    Replies:
    2
    Views:
    441
    shapper
    Jan 7, 2008
  4. Jochen Brenzlinger
    Replies:
    7
    Views:
    5,680
    Roedy Green
    Sep 15, 2011
  5. He Who Greets With Fire

    Rename File Using Strring Found in File?

    He Who Greets With Fire, Mar 4, 2008, in forum: Perl Misc
    Replies:
    19
    Views:
    229
    Martijn Lievaart
    Mar 7, 2008
Loading...

Share This Page