I want to delete duplicate files made by itunes, which all end in ” 1.mp3″. I’ve come close to matching but I don’t know how to match the space. Can somebody writeup a command to recursively delete those files from the current directory?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You want to go through your iTunes collection and remove Nickelback’s If I care 1.mp3 but, only if the Nickelback original MP3, If I care.mp3, still exist. Right?
Hey, your musical tastes are up to you…
This should do the trick:
I am finding all the duplicates (songs that end in space-1.mp3) and piping them to the
whilestatement.The
${word%filter}syntax says take the$wordand remove from the right hand side the glob expressionfilter. Thus,${file% 1.mp3}is the name of the file sans the1.mp3suffix. Now,If I care 1.mp3becomesIf I care. We, therefore need to add the.mp3suffix back on. Thus${file% 1.mp3}.mp3. This gives us the original name of the file.Now, we use
-etest to check if that file exists. If it does, we can delete the space-1.mp3 version of the song.I ran some basic tests, but I suggest you try it out first (maybe change
rm $filetoecho Removing file $filefirst and verifying that those files do have the original).