You can do that with a small Perl script very easily. Following Perl code does what you want, but only for 1 hierarchy:
Code:
#!/bin/env perl
use Getopt::Long;
$root_dir = ".";
GetOptions (
"d=s" => \$root_dir,
);
print "$root_dir\n";
foreach $dir (glob "$root_dir/*") {
print "Processing $dir\n";
if (glob "$dir/*.jpg" == "") { print "The directory $dir has no JPEG files. Skipping...\n"; }
mkdir "jpg";
system ("mv ".glob ("$dir/*.jpg")." $dir/jpg");
}
Save it as something like mv_jpeg.pl and make it executable by chmod 755 mv_jpeg.pl.
Now you can call it in any root directory you want:
Code:
./mv_jpeg.pl -d some_dir
This creates in each subdirectory under "some_dir" a sub-sub-directory called "jpg" and move all files in the subdir with the extension "*.jpg" into this folder.
You can modify the script in the way you want.
With little effort it can be recursive.
Bookmarks