Recursively delete all flac's in subdirectory, but leave the remaing alone

Hi,

Originally, I ripped my music with FLAC and used folder.jpg at various levels of the folder hierarchy. Now, after converting the FLACs to ALACs and embedding the artwork, I want to get rid of these old FLACs, but keep the folder hierarchy with the associated folder.jpgs inside (I have a lot of Artists .jpgs that I might want to use someday.

The high level folder is called "Old Music", and this is where I want the FLACs removed. I don't want to touch any other sibling folders for this command.

What Terminal command can I run to accomplish this task? I have a copy of my real ALAC files, but not these old FLACs. They're taking up too much room, so I need to delete them.

Thanks.

24" iMac 3.06 GHz Core 2 Duo/1 TB/8 GB; MBP 17" Core 2 Duo/Santa Rosa, Mac OS X (10.6.5), Parallels v6 with Win7 x64; iPod Touch 2G; iPhone 3GS (4.2.1); iPhone 4 (4.2.1)

Posted on Dec 14, 2010 6:45 AM

Reply
22 replies

Dec 15, 2010 5:59 PM in response to Kappy

Yes Kappy:


cd "/volumes/media/old music";ls
.
.
.
Yo-Yo Ma
ZZ Top
imac:old music johndoe$ cd "zz top"
imac:zz top johndoe$ ls
The Best of ZZ Top folder.jpg
imac:zz top johndoe$ cd "the best of zz top"
imac:the best of zz top johndoe$ ls
01-Tush.flac 05-Just Got Paid.flac 09-Beer Drinkers and **** Raisers.flac
02-Waitin' For the Bus.flac 06-La Grange.flac 10-Heard It On the X.flac
03-Jesus Just Left Chicago.flac 07-Blue Jean Blues.flac folder.jpg
04-Francine.flac 08-Backdoor Love Affair.flac
imac:the best of zz top johndoe$ rm -rf *.flac
imac:the best of zz top johndoe$ ls
folder.jpg
imac:the best of zz top johndoe$


That seems to work fine.

Dec 15, 2010 7:08 PM in response to Kappy

I did the cd ....;ls just to show you what's under "old music" in one fell swoop. I know the ls just lists the contents of a dir.

They're not directories, since the rm -rf *.flac removed them all from the ZZ Top directory (except the folder.jpg like I wanted). Now I have to figure out how to get rm to work at a high level.

Dec 16, 2010 4:41 AM in response to Kappy

Kappy,

That command:


imac:old music johndoe$ find "/volumes/media/old music" -type f -name "*.flac" -exec rm -f {} ;


seems to be working (I'm verifying it from Finder). I guess the rm command by itself couldn't traverse the directory path, deleting along the way. Only using find to locate the files; then passing them to rm did the trick. Thanks for the tip.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Recursively delete all flac's in subdirectory, but leave the remaing alone

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.