Go Back   The macosxhints Forums > OS X Help Requests > UNIX - Newcomers



Reply
 
Thread Tools Rate Thread Display Modes
Old 06-14-2004, 10:45 PM   #1
Luck
Prospect
 
Join Date: Jun 2004
Posts: 1
Copying all files of a type to a folder

Howdy.

I know there must be a way to do this, but I am unsure how.

iTunes has messed up my mp3 collection, duplicating many files. For example, in the library there are "Song", "Song 1", "Song 2", etc, that are all copies. I don't really know why this occured, but it has eaten up much of my free hard drive space.

Thus, I would like to take every .mp3 file on my Mac and put them in one folder. Then I would manually delete the dupes, giving me my normal collection back and freeing up space.

Trying to do the copy in the GUI is too much for my little G4 to handle, as with duplicates it's something like 4000 files.

My question: How would I move all the .mp3 files on all disks to one folder using Terminal? Probably mv something, but I really don't know Unix much.

Thanks for the help.
Luck is offline   Reply With Quote
Old 06-15-2004, 12:50 AM   #2
ulrichm
All Star
 
Join Date: Oct 2003
Location: The Netherlands
Posts: 741
What you can do is use the 'find' feature of the Finder and search for all mp3s on your computer.
Once found, you drag all the files you wish to a new folder. The Finder will then move your mp3s to this new folder.
I have also a G4 and it copes well with almost 1000 mp3s.
__________________
..::|| Mac-addict since 1991 ||::..
ulrichm is offline   Reply With Quote
Old 06-15-2004, 08:35 AM   #3
acme.mail.order
League Commissioner
 
Join Date: Sep 2003
Location: Tokyo
Posts: 6,057
For deleting the duplicates, a brief web search produced this nifty script:
Code:
#!/bin/bash
OUTF=rem-duplicates.sh
echo "#! /bin/sh" > $OUTF
find -type f | while read x
 do md5sum "$x"
done | sort --key=1,32 | uniq -w 32 -d --all-repeated=separate | sed -e "s/^/#rm \"/g" -e 's/$/\"/g' >> $OUTF
chmod a+x $OUTF
ls -l $OUTF
I've edited it to remove the slightly buggy filename escapes and replace them with quotes. It does NOT keep one of the duplicates - you must edit the script output file manually to figure out which duplicates get deleted.
acme.mail.order is offline   Reply With Quote
Old 06-19-2004, 03:06 PM   #4
FiercePanda
Prospect
 
Join Date: Jun 2004
Posts: 7
if you just want to move all your mp3s to a folder, you could try the following:

mkdir /mp3folder; find / -name '*.mp3' | xargs -i mv \{\} /mp3folder

(I should mention that I'm still on jaguar, and my xargs command doesn't have the -i option, I hope they've added it for panther...).
FiercePanda is offline   Reply With Quote
Old 06-19-2004, 03:49 PM   #5
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
Exclamation caution

Quote:
Originally Posted by FiercePanda
if you just want to move all your mp3s to a folder, you could try the following:

mkdir /mp3folder; find / -name '*.mp3' | xargs -i mv \{\} /mp3folder

this could be destructive. for example, finding these results:

Art Blakey Quintet/A Night At Birdland/A Night In Tunisia.mp3
Lee Morgan/The Best Of Lee Morgan/A Night In Tunisia.mp3


the mv command would destroy Art Blakey's version.
mervTormel is offline   Reply With Quote
Old 06-19-2004, 11:35 PM   #6
FiercePanda
Prospect
 
Join Date: Jun 2004
Posts: 7
Quote:
Originally Posted by mervTormel
this could be destructive. for example, finding these results:

Art Blakey Quintet/A Night At Birdland/A Night In Tunisia.mp3
Lee Morgan/The Best Of Lee Morgan/A Night In Tunisia.mp3


the mv command would destroy Art Blakey's version.

Good point. That didn't occur to me, as I have mv aliased to 'mv -i' for safety. I still can't think of an easy way to get all the duplicates renamed and moved into the same directory though.
FiercePanda is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 09:57 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.