Gabriel Sechan wrote:
Is shell necessary? Here's my idea in perl (note- no testing was actually done, may have minor bugs, run on a test directory before applying to the whole dataset):#list all mp3 files @files=`ls $origDir*.mp3`; #loop over list of files, processing each foreach my $fileName (@$files){ #parse out the artist and song $fileName =~ m/(.*) - (.*)/ or die "Song $fileName in wrong format"; my $newFileName="$1/$2"; #make sure that the subdir exists, if not create it if(!(-e $1)){ mkdir($1); } #do the move rename($fileName,$newFileName); } Gabe
Certainly the shell is not needed. As you suggest it can be done in perl (and I'm sure python, etc.). I've been trying to learn a bit more shell programming and thought this would be a good exercise. Maybe too good of an exercise.
I think the problem with the original shell script isn't in the sed part, but related to the -exec command in find. I have taken your advice, Gabe, and just complete a perl script that does the job.
Thanks to all who offered suggestions. Karl -- [email protected] http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list
