Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PERL

Move files to new directory

foreach my $file (@files) 
{
    my $old = "$srcdir/$file";
    my $new = "$dest/$file";
    my $subdir = $file;
    while (length($subdir)>0)
    {
        if (-d "$dest/$subdir")
        {
            $new = "$dest/$subdir/$file";
            last;
        }
        chop($subdir);
    }

    rename($old, $new) or die "Move $old -> $dest failed: $!";
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Move #files #directory
ADD COMMENT
Topic
Name
4+1 =