Horje
Move files to new directory Code Example
[Solved] - Move files to new directory Code Example
Try following codes
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: $!";
}
Date: 2022-05-21 05:02:10
Category: perl
More for You