Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Shorten windows paths too long

by gj2666 (Sexton)
on Aug 17, 2010 at 18:29 UTC ( #855561=note: print w/ replies, xml ) Need Help??


in reply to Re: Shorten windows paths too long
in thread Shorten windows paths too long

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.


Comment on Re^2: Shorten windows paths too long
Re^3: Shorten windows paths too long
by SuicideJunkie (Priest) on Aug 17, 2010 at 19:21 UTC

    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 :)

      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://855561]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (11)
As of 2014-07-30 09:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (230 votes), past polls