Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 1 down vote accepted

Try with this

find /mount/point/of/z -type d -name '*flac*' | while read dir
   newdir=`echo $dir | sed -e 's/\[flac\]/\[mp3\]/'`
   mkdir -p "$newdir"
share|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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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