That is exactly what I'm trying to do here. Rename directories programmatically to make the paths shorter i.e. more succinct. I have something like 70 of them and each path requires about 4 or 5 renames to shorten by 30 or so characters.
Trying to get them all done in one day to move the whole mess to a shorter path root. (i.e. c:\hw instead of c:\softwaredistribution
Unfortunately we can't move the folders until the path is < 256 characters.
| [reply] |
What if you were to build a multilevel hash to lookup the conversions?
BFS the filesystem tree, and rename the first folder you see to 'a', the second to 'b' and so on using the magic increment. Recurse down the tree until you have 'c:\RootOfEvil\a\b\a\c\a\a\f\a\b\filename.ext'
Your hash tree would tell you that $treeHash->{a}{b}{a}{c}...{f}{a}{b} was originally named 'debug' and $treeHash->{a}{b}{a}{c}...{f}{a} was originally named 'bin', and so on, so that you can undo the renames later.
You'd end up renaming 'c:\RootOfEvil\BigNameLevel1' to 'c:\RootOfEvil\a', and then moving on to rename 'c:\RootOfEvil\a\BigNameLevel2' to 'c:\RootOfEvil\a\a' and so on.
Or, much more simply... what if you just pile the whole tree into an archive, copy that across, and then unpack it on the other side, leaving the archiver app to deal with the excessive tree :)
| [reply] [d/l] [select] |
Or, much more simply... what if you just pile the whole tree into an archive, copy that across, and then unpack it on the other side, leaving the archiver app to deal with the excessive tree :)
Um yeah, zip utilities generally crash on pathname too long. (i've already got that t-shirt)
Hmm. magic increment. I will continue to investigate. Thanks for the suggestions.
| [reply] |