Ooops, need a one liner!

Joe joe at nationnet.com
Fri Jul 3 16:47:50 MST 2009


Not a one liner, but a small shell script. Remove the echo after you 
test it to actually move the files.

------- cut here ------
#!/bin/bash

mus_dir="music"

find ~/$mus_dir -name '*.ogg' -print0 | while read -d $'\0' file
do
        nf=`echo $file | sed "s/$mus_dir/ogg_music/"`
        nd=`dirname "$nf"`
        if [ ! -d "$nd" ] ; then
                mkdir -p "$nd"
        fi
        echo mv "$file" "$nf"
done
---- end here ----

Ryan Rix wrote:
> Hey guys,
>
> I recently recovered about 20gb of ogg music off of my old laptop (or rather, 
> a backup of it existing on my dad's computer) and decided to merge it with my 
> current collection, which is about 90% mp3. I didn't think before I merged 
> them, but I ended up creating about 20 albums where the tracks exist in both 
> OGG and MP3. Also, it appears that MANY of the tags on the ogg music are 
> absolutely cooked (or amarok's database is)
>
> So, does anyone know a way that I can take bash and tell it to:
>
> Find all the ogg files in ~/music, move them, while creating the same 
> directory structure, under ~/ogg-music ?
>
> I'd use amarok's organize files utility, but it dies horridly on this many 
> files.
>
> (I'll be out all day, and perhaps all weekend, so pardon me if I don't 
> immediately reply.)
>
> Ryan
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>   


More information about the PLUG-discuss mailing list