Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
I tried super search before I decided to post here. I understand that Windows does not support pathnames longer than 256ish. However, I have paths longer than that on disk. It seems that on my Hudson build server (win32) Java/Maven/Hudson or some other evil entity insists on writing those "paths too foul" to my disk.

The evil Java build automation developers I work with want to move the Hudson jobs to a different location, however the paths are too long and windows just whines when I try to move them. (see output at bottom)

I could alter them manually by changing several paths manually, but whenever the job runs again it updates whatever was there with the current path too foul. Can't get them all renamed manually before new ones are created.

So I tried something I found here the other day, but it fails to execute the move command here: (And yes, I have wicked skills, but not in a good way.)

H:; cd $olddirname; cd ..; move /Y $olddirname $newname` or die "Can't + move $olddirname $newname: $!";
$olddirname is the full path to the dir I want to rename (shorten). $newname is the new name of the dir (no path) executed (via the ..) to position me in the parent dir of the one I want to change. My question is...what is another approach that I could make work since making a system call and using the dos commands seems to be a bust.
#!perl # # fixlength.pl # Script to browse a file path (for hudson jobs)and find "target" # directories and shorten the pathname by renaming several common # directory names dir /s /b Zz* # $File::Find::dir = /some/path/ # $_ = foo.ext # $File::Find::name = /some/path/foo.ext # use strict; use warnings; use File::Find; #used to traverse a directory tree my $count; my $char; my @pathname; # open (FILE, "<$file") or die "Can't open $file: $!"; my $directory = "H:/softwaredistribution/hudson/jobs/"; finddepth(\&process_file, $directory); #---------------------------------------------------------------- # Sub Routines start here #---------------------------------------------------------------- sub process_file{ foreach (my $dir = $File::Find::dir){ my $dir1=$File::Find::name; if (($_ ne "\.")&&($_ ne "\..")){ print "Dir is : $File::Find::dir \n file is :$_ \n and fu +llpathname is : $File::Find::name \n"; my %rephash=("target"=>"t", "checkout"=>"co", "was6-maven- +plugin"=>"w6","SNAPSHOT"=>"S"); my @keys = %rephash; my @value = %rephash; foreach my $key (sort keys %rephash){ if ($dir1=~m/$key$/) { my $olddirname=$dir1; $_=$dir1; # s/$key/$rephash{$key}/g; my $newname=$rephash{$key}; print "Command is H:; cd $olddirname; cd ..; move +/Y $olddirname $newname \n"; `H:; cd $olddirname; cd ..; move /Y $olddirname $n +ewname` or die "Can't move $olddirname $newname: $!"; } } } } }
Output:
H:/softwaredistribution/hudson/jobs/Conservation_Payment_Release/workspace/trunk/target/checkout/conservation-ejb-batch/target/was6-maven-plugin; cd ..; move /Y H:/softwaredistribution/hudson/jobs/Conservation_Payment_Release/workspace/trunk/target/checkout/conservation-ejb-batch/target/was6-maven-plugin w6

Can't move H:/softwaredistribution/hudson/jobs/Conservation_Payment_Release/workspace/trunk/target/checkout/conservation-ejb-batch/target/was6-maven-plugin w6: at O:\RatlSupport_ML_dev\SRM-SoftwareDevCV\RatlSupport\Scripts\fixlength.pl line 42.

Line 42 is the `H:;...` In the output above we're trying to move (rename was6-maven-plugin to "w6").

All the output in trunk and below gets rewritten on build machine each new build and never commits to the SVN repository to it's okay to change on this server.

Thank you for your time and patience. gj


In reply to Shorten windows paths too long by gj2666

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (5)
    As of 2014-11-29 08:57 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My preferred Perl binaries come from:














      Results (204 votes), past polls