Login | |
|
 |
Renamer script... - 3/28/2007 8:23:01 PM
|
|
 |
|
| |
markmcrobie
Posts: 314
Score: 0
Joined: 12/12/2006
Status: offline
|
...will be pretty useless to most people, as it's designed with a very specific task in mind that won't apply to most, but it's taken me months to get it to this stage, and I'd never used any kind of programming code before, so I'm pretty proud of it - thanks to all who helped with it on these forums. Background: We have to export documents from our Hummingbird Document Management System and transfer them to a PC that's on another network. The problem is Hummingbird exports them using it's own internal numbers/data in the format: <library name>-#<internal doc number>-<library version>-Name_of_file_with_underscores_for_spaces For example: BERTHING_U-#12345-v1-Nuclear_Safety_Broadcast_System_Design.PDF Which I'm sure you'll agree is pretty unreadable, especially if you have lots of files like this. Also we need to have 3 other fields from within Hummingbird in the new file name, but Hummingbird won't let you choose which field names to export as part of the name. So before my script came into existence, we had to manually rename each file, removing the BERTHING_U-#12345-v1- bit, find the other 3 fields values for that file by looking in Hummingbied, append them to the start of the file name, and remove all underscores. Remember this was done manually, within Windows Explorer. And we can do hundreds of files at a time. So my script started as a 6 liner, trying to automate this labourious task a bit. It grew & grew, it's now 243 lines! In summary, here's what it does: 1) Offer the user to pick a folder where the candidate files for renaming are 2) Set some Regular Expressions to find the text, etc, I want to get rid of 3) Loop through all the files in the chosen folder, finding any candidates for renaming 4) Offer the user the chance to type in the info from the extra 3 fields 5) Rename the files 6) Once done offer the user the chance to e-mail them or queue them to burn to CD (depending on size) It works very well. As I said I don't think as a whole that many people will have a use for it, but it's pretty well commented and someone somewhere might find a use for a technique used in it or a section of it For the sake of easier reading, I'll post it in a separate post.
|
|
| |
|
|
|
|
|