dimar has asked for the wisdom of the Perl Monks concerning the following question:
While working on my little 'batch file rename' tool I came across a semi-roadblock. As I suspected, Super Search revealed that I wasn't the first person in the world to go down this path, and batch file rename is a well worn topic to say the least. Great! I was able to see how other people had approached the same problems I had encountered, as well as get some new ideas. Nevertheless, there were some problems not already addressed (AFAICT) in the previous posts on this topic.
My script is actually working fine as-is, but I would like to enhance the functionality of my little renaming tool (the general spec for the tool is listed below). These areas need improvement:
1) Under "rename htm based on content" I need a way to specify in the filename
whether an htm file has already been renamed based on the title tag, so as
to let the script skip over htm files it has already renamed in the past. {fn1}
What is a good way to do this?
2) Under "global-preview-before-rename" what is a good way to let the user
"eyeball" the proposed rename operations before they are carried out?
A GUI checklist would be nice, but simplicity is preferred.
Is there a way to allow the user to individually 'select and deselect'
from a list of proposed renames before the operation is carried out?
=for comment ### Definitions "ugly characters" ;; chars either not allowed or desired "too long" ;; maximum allowable length for a basename "basename" ;; file-full-path minus file-extension "file-extension" ;; anything that satisfies m/\.[^\.]+$/ "rename suprises" ;; unexpected results from a batch rename ### standard operations rename extension (eg *.foo to *.fee) rename basename (eg ibm*.* to IBM*.*) routine replace (eg lower-case to upper-case) ### file-management operations rename and move rename and copy rename to non-yet-existent location (mkpath-style) ### scrubbing operations remove all "ugly characters" replace all "ugly characters" with a safe char (eg "_") reduce all "too long" names to a truncated shorter name (and allow the user to specify truncate rules) (and prevent "rename collision" on non-unique truncations) ### safeguard operations avoid "rename collision" by halting the program avoid "rename collision" by appending UniqueID avoid "rename suprises" with global-preview-before-rename ### rename based on content rename htm file by the content of the <title> tag (and apply all scrubbing operations) (and skip the rename if already been done before) rename htm file by some UniqueID if no <title> tag exists ### rename based on context rename to include all directory-path-steps as part of the name rename to include the last 2 path-steps as part of the name =cut
{fn1} The current approach for renaming htm based on title tag is to grab the content of title tag (if it can be grabbed); scrub it; apply a 'counter tag' to the end to prevent renaming collisions; and use the counter tag (eg m/xx\d+/) as a 'search anchor' to test if the htm file was already renamed by this tool in the past.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Batch Rename Question (YABRQ): Rename on content and Global Preview
by ikegami (Patriarch) on Nov 05, 2004 at 01:37 UTC | |
|
Re: Batch Rename Question (YABRQ): Rename on content and Global Preview
by BrowserUk (Patriarch) on Nov 05, 2004 at 02:55 UTC | |
|
Re: Batch Rename Question (YABRQ): Rename on content and Global Preview
by gaal (Parson) on Nov 05, 2004 at 05:27 UTC | |
|
Re: Batch Rename Question (YABRQ): Rename on content and Global Preview
by ikegami (Patriarch) on Nov 05, 2004 at 01:42 UTC | |
|
Re: Batch Rename Question (YABRQ): Rename on content and Global Preview
by TedPride (Priest) on Nov 05, 2004 at 04:58 UTC |