Move Files To New Directory

[Solved] Move Files To New Directory | Perl - Code Explorer | yomemimo.com
Question : Move files to new directory

Answered by : vternal3

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 : https://stackoverflow.com/questions/5836679/perl-moving-files-into-dedicated-folders | Last Update : Tue, 19 Oct 21

Answers related to Move files to new directory

Code Explorer Popular Question For Perl