P
P B
I'd like to create a (Linux) perl command line utility that creates
subdirectories based on a common part of several filenames and then
moves the corresponding files into them. The command would (ideally)
look something like this:
makesubdirs.pl 's/^([a-zA-Z+)_\d{2}\.[a-zA-Z]{3}$/$1/' *
If it was issued in a directory containing, for example, the following
files:
image01.jpg
image02.jpg
movie01.mpg
movie02.mpg
it would create an 'image' subdirectory and a 'movie' subdirectory and
move the files, etc., you get the idea.
So, how can I pass the whole s/// operator to the program, to be used
(presumably) thusly (to continue the example used above):
my $pattern = shift @ARGV;
my $subdirectory =~ $pattern;
.... and so on to create the subdirectories, etc.?
Thank you.
subdirectories based on a common part of several filenames and then
moves the corresponding files into them. The command would (ideally)
look something like this:
makesubdirs.pl 's/^([a-zA-Z+)_\d{2}\.[a-zA-Z]{3}$/$1/' *
If it was issued in a directory containing, for example, the following
files:
image01.jpg
image02.jpg
movie01.mpg
movie02.mpg
it would create an 'image' subdirectory and a 'movie' subdirectory and
move the files, etc., you get the idea.
So, how can I pass the whole s/// operator to the program, to be used
(presumably) thusly (to continue the example used above):
my $pattern = shift @ARGV;
my $subdirectory =~ $pattern;
.... and so on to create the subdirectories, etc.?
Thank you.