Menachem Shapiro wrote:
B"H
On 3/4/06, Karl Cunningham <[EMAIL PROTECTED]> wrote:
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.

I realize the point is way moot by now, but what about something like this:

#This assumes that:
#a) you are running this from the directory that has all the directories in it.
#b) this is the root folder for all the mp3s

## ls -F marks all the directories with a slash '/', grep for slash
and then remove it.
for i in `ls -F |grep \/ |sed -e "s/\///"`
do
     # '-print0' and 'xargs -0' should take care of any spaces.
     # searches for directory name in any part of the file
     find . -name "*${i}*" -print0 |xargs -i -0 mv {} $i;
done

Menachem --

Thanks for the suggestion. I wasn't very clear about it but the problem was with the find -exec part of things and not with sed. I got hung up with where to put quotes and whether to escape them. As someone in this thread said it's often a matter of trial and error until you get it right. I made a lot of trials but mine all resulted in error, either outright errors or it didn't do the right thing.

I finally gave up and wrote it in perl, which does the job just fine.

Karl


--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to