What about using symlink on directories (I needed it)?
Just a simple example that works quite well (I haven't tested it extesively).
if( (-f $file) and ( ! link( $file, $new )) ) { warn "Can't link $file to $new: $!\n"; } elsif( (-d $file) and ( ! symlink( $file, $new )) ) { warn "Can't symbolic link $file to $new: $!\n"; } else { $did= 'ln'; }
In the ProcessFile subroutine.
And recursive directory structure creation (just like mkdir -p)?
This is made using the subroutine make_path in File::Path instead of mkdir to create directories.
use File::Path qw< make_path >; # this should be added at the t +op sub MakeNewDirs { my( @newDirs )= @_; for my $dir ( @newDirs ) { if( -d $dir ) { warn "mkdir $dir: Already exists.\n"; } elsif( make_path( $dir ) ) { warn "mkdir $dir\n"; } else { warn "Can't mkdir $dir: $!\n"; } } }
Anyway thank you for sharing.
In reply to Re: mvi -- mv+vi (+ln+rm+cp+mkdir)
by alexbio
in thread mvi -- mv+vi (+ln+rm+cp+mkdir)
by tye
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |