Answers for "move files named with certain to new folder"

0

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: $!";
}
Posted by: Guest on October-12-2021

Code answers related to "move files named with certain to new folder"

Browse Popular Code Answers by Language