The internet is the best

Specifically, Stack Exchange is the best.

I have an mp3 collection of Vivaldi’s complete works, which I acquired by…certain unspecified means, and all the mp3 files were arranged in sub-directories and sub-sub-directories, which is kind of a pain in the ass. So I wanted to copy all the mp3 files from these various depths of directories into a single, sub-directory-less folder.

After a few searches led me to some answers telling me how to copy a bunch of files of a certain type to a different folder while preserving the directory structure, I wised up and removed “recursive” from my search terms and found this wonderful thread at Stack Exchange. The question says, “Linux: Copy all files by extension to single dirrectory [sic]”. The user wanted to copy all files of a certain type from a series of folders and sub-folders to a new folder without preserving the folder tree. Just like me!

The answer that received the most votes and that worked for me was (after cd’ing into the top folder of this complete works collection):

find . -name "*.TIF" -exec cp {} new \;

except, of course, I replaced “TIF” with “mp3” and “new” with the full path of the destination folder.

So the find command is pretty useful. It can find all kinds of things. For instance, it can find files that have a certain set of permissions or that were modified on or after a certain date. I had never used it before today. I’m slowly inching my way up from Linux beginner to intermediate user…

This entry was posted in Computers, Interwebs, Linux. Bookmark the permalink.

Comments are closed.