Quick Tip: Extracting all files in multiple folders in Linux

I just got sent a bunch of backup snapshots nicely compressed in RAR format in 20Mb segments in multiple folders. Nice I thought, now you’d have to iterate through 80 folders, and extract each rar file and merge them all into the same folder.


So I threw the files onto our linux box (didnt want to run this through Cygwin) and knocked up a little gem to iterate through all the folders and extract the RAR files and put them into the root folder.

find -type f -name ‘*.rar’ -exec unrar x {} \;

Nice and neat. This uses the find command to iterate through all the RAR files and executes the unrar command. In order to get this to work, you should get (in my case) the Backup folder and execute the above, then it will iterate through (again in my case) the /AcronisTrueImage.*/ backup folders and find the rars and uncompress them to Backups folder.

On the subject of backups, the only solution you ever need is Acronis True Image, I’ve trusted them to manage our backups for close to 7 years now (True Image Deluxe even had ReiserFS support in 2002), I use Echo Workstation but Home would suffice for most.

Related Articles

Comments have been disabled.