# Rename to txt file - file not found in list,but in directory

**URL:** <https://www.ruby-forum.com/t/rename-to-txt-file-file-not-found-in-list-but-in-directory/155415>\
**Category:** Ruby\
**Created:** [December 11, 2008, 4:57pm UTC](https://www.ruby-forum.com/t/rename-to-txt-file-file-not-found-in-list-but-in-directory/155415 "2008-12-11T16:57:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmcolli00](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/85e7bf/32.png) [@mmcolli00](https://www.ruby-forum.com/u/mmcolli00)\
**Post date:** [December 11, 2008, 4:57pm UTC](https://www.ruby-forum.com/t/rename-to-txt-file-file-not-found-in-list-but-in-directory/155415/1 "2008-12-11T16:57:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mmcolli00](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/85e7bf/32.png) [@mmcolli00](https://www.ruby-forum.com/u/mmcolli00)\
**Post date:** [December 12, 2008, 4:54am UTC](https://www.ruby-forum.com/t/rename-to-txt-file-file-not-found-in-list-but-in-directory/155415/2 "2008-12-12T04:54:31Z")

</div>

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
