Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

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
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
add comment

Your Answer

 
discard

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.