laziness, impatience, and hubris | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Hello all,
I recently completed a small project here at work that involved renaming files based on existing file names. All of the files are named like this: a 10 digit base number, 1 letter 'x', an optional number, then the extension '.las'. Many of the files share the same base number so that's why the optional number after the letter is needed.
There are around 4,000 files already on a network drive. New files that are to be added, need to have their prospective names compared to the existing files and the optional number added or incremented to make sure nothing will be overwritten. The files are then moved to a different folder to verify their header information before being moved to the final directory. Here's the code I used originally, and although the initial file globbing is slow, the actual renaming is quite fast.
Just this morning, I found this post on Renaming Files by tachyon and it looked like it would work more efficiently than mine. I modified it to fit my situation and found that it DID work better than my original. Here's the new code I used: This works exactly like I need it to. So many thanks to you, tachyon, for sharing your code. One thing that puzzles me though is why it takes so much longer for the file globbing in the original code than it does in the newer code Can anyone explain this? Thanks in advance! ^l9v In reply to Dynamic file renaming and globbing by licking9Volts
|
|