Moderators: SecretSquirrel, notfred
#!/bin/bash
TOP_DIR=/music
NEW_DIR=/media/music
for i in `ls $TOP_DIR`; do
if [ -d $i ]; then
for j in `ls $TOP_DIR/$i`; do
if [ -d $j ]; then
mv $TOP_DIR/$i/$j/*.flac $NEW_DIR/
mv $TOP_DIR/$i/$j/*.ogg $NEW_DIR/
mv $TOP_DIR/$i/$j/*.mp3 $NEW_DIR/
fi
done
fi
donefind . -type f | egrep '\.flac$|\.mp3$|\.ogg$' | sed -e 's:^:mv ":;s:$:" destination-folder-name:' | bashPFarkas wrote:Try this. It's pretty straightforward.
FOR /R %i in (*.mp3) do Move "%i" \destination
Where \destination is the target for your files.
This will perform a MOVE operation on all of the files with a .MP3 extension to the target directory.
If you're skittish, you could replace Move with Copy, which would, of course, create a copy.
If you want to move ALL the files, replace *.MP3 with *.*
just brew it! wrote:Caveat: My previous example will lose files if there are any name collisions. So be certain there are no duplicate names first...
just brew it! wrote:Or a one-liner:
- Code: Select all
find . -type f | egrep '\.flac$|\.mp3$|\.ogg$' | sed -e 's:^:mv ":;s:$:" destination-folder-name:' | bash
There's probably a less convoluted way to do it with xargs, but the above was the first thing I came up with.
find . \( -name '*mp3' -o -name '*flac' -o -name '*ogg' \) -type f -print0 | xargs -n1 -I@ -0 mv @ destination-folder-namefind . \( -name '*mp3' -o -name '*flac' -o -name '*ogg' \) -type f -print0 | xargs -0 mv -t destination-folder-namejust brew it! wrote:Heh... the xargs solution isn't really that much easier to understand (and is actually longer) than my solution. I think I'll stick with my find/sed/bash pipeline method for stuff like this!
james brown "the boss".mp3mv "./mp3s/james brown "the boss".mp3" destination-folder-nameAlthough I Dropped $100000 (I Found a Million Dollars in Your Smile).mp3Return to Linux, Unix, and Assorted Madness
Users browsing this forum: No registered users and 2 guests