Jano Svitok
8/1/2007 1:36:00 PM
On 8/1/07, Peter Bailey <pbailey@bna.com> wrote:
> ChrisH wrote:
> > See inline comments
> > On Aug 1, 8:25 am, Peter Bailey <pbai...@bna.com> wrote:
> > ...
> >> Dir.chdir("L:/tiff/cdtiff/00000")
> >> Dir.glob("*.tif").each do |tiffile|
> >>From the docs look like it creates an array of matched filke names
> > then
> > iterates, placing current filename in tiffile...
> >
> >> File.rename(tiffile, tiffile.downcase)
> > Rename the file to be lowercase, value in tiffile(and in the array
> > created by Dir.glob) is unchanged...
> >
> >> pdffile = File.basename(tiffile, ".tif") + ".pdf"
> > I think base name is case sensitive, so ".tif" does not match '.TIF'
> > so .pdf is appended instead
> > of replacing '.TIF'
> >> puts "#{tiffile} #{pdffile}"
> >> end
> >>
> >
> > When you go look at the directory the files are in lowercase because
> > your script has made them so.
> > Have you tried re-running on the dir of lower-case names?
> >
> > Cheers
> > Chris
>
> I don't understand. Yes, I've made them lower-case, and then, I'm just
> listing them. I'm a Windows guy and this whole case business is new to
> me, but, I'm learning to have to deal with it. That's why I lower-cased
> all the files to start with. So, if they're lowercase, why would they
> display as upper-case?
1. You have to work with the new filename. I.e. after you rename the
file, set the new file name as well, otherwise you'll be working with
the old name.
File.rename(tiffile, tiffile.downcase)
tiffile = tiffile.downcase # <<< THIS IS IMPORTANT!!!
pdffile = ...
- OR -
newtifile = tiffile.downcase
if newtiffile != tiffile
File.rename(tiffile, newtiffile)
tiffile = newtiffile
end
pdffile = ... tiffile...
2. Sometimes windows shows uppercase filenames in lowercase -- (I'm
guessing that)
when on FAT && the filename is in 8.3 format (=has no lfn) -- you can
check with full dir