0

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.

Dennis Williamson
  • 60,515
  • 14
  • 113
  • 148
LVLAaron
  • 436
  • 6
  • 13

1 Answers1

1

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
Hrvoje Špoljar
  • 5,162
  • 25
  • 42
  • 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