I need to do a z:\music\: dir *flac* to get a listing of directories... (they are named Artist - Album [flac])

and from that list of directors, create new matching directories, but replace the [flac] part with [mp3]

I can do this from linux, or windows. Either is available.

link|improve this question

80% accept rate
feedback

1 Answer

up vote 1 down vote accepted

Try with this

#!/bin/bash
find /mount/point/of/z -type d -name '*flac*' | while read dir
do
   newdir=`echo $dir | sed -e 's/\[flac\]/\[mp3\]/'`
   mkdir -p "$newdir"
done
link|improve this answer
If I enter "find /mount/point/of/z -type d -name 'flac' | while read dir" I just get the carat > – LVLAaron Feb 24 '11 at 18:17
But the script worked beautifully. If you cared to explain what's up with the first line I'd really appreciate it... – LVLAaron Feb 24 '11 at 18:19
first find as you suggest with 'flac' wont find anything as that would be looking for exactly directories named 'flac' not ones containing flac, thats why i wrote 'flac' ... basically script finds all dirs that contain flac, and substitutes flac string for mp3 string with the sed command, then after it creates directory that contains switched strings flac -> mp3 – Hrvoje Špoljar Feb 24 '11 at 18:32
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.