VIPVEGAS
VIPVEGAS

Reputation: 3

Unzip files in multiple subdirectory to one folder in MacOs in beginners terms

Im new to mac and believe this is what Im looking for from search. Do I just type this in terminal as is below? Can someone explain step by step for a beginner to mac?

I have 1000 sub folders with multiple zip files in each want to unzip at once to a single folder

find ./ -name *.zip -exec unzip {} \;

What if Im trying to unzip them to a different harddrive location. Where do I put the output location to the other harddrive?

Thanks

Upvotes: 0

Views: 2301

Answers (2)

petrubear
petrubear

Reputation: 721

Yes, you have to type that on your terminal, with those arguments you have to be in the directory the zip files are for it to work. What does it do:

find is a commnad that lets you "find" files the first argument ./ tells find where to start searching, in this case, the current folder, you can tell find to seach into any folder you want by replacing this argument por example find /Users/me/Documents -name *.zip tells find which files to look for, in this case any file with a .zip extension, you should use -iname *.zip just un case you have files with any case (uppercase or lowercase zip extension), -exec tells find that you wanna execute a program for each file it finds, in this case you want to execute te command unzip, finally {} tells find where to use the file it found as an argument for the program you want to call with exec and \; marks the end of the exec command

Upvotes: 0

zedfoxus
zedfoxus

Reputation: 37129

You could try something like this:

find . -type f -name '*.zip' -exec unzip {} -d ~/zipout/ \;

assuming you have a folder called zipout in your home directory.

On your command line, try to do this:

$> man unzip

You will see its syntax:

unzip [-Z] [-cflptTuvz[abjnoqsCDKLMUVWX$/:^]] file[.zip] [file(s) ...]  [-x xfile(s) ...] [-d exdir]

See the switch -d. That tells unzip where to put your extracted files/folders.

[-d exdir] An optional directory to which to extract files. By default, all files and subdirectories are recreated in the current directory; the -d option allows extraction in an arbitrary directory (always assuming one has permission to write to the directory).

So, that's the option I used along with find and exec.

Upvotes: 2

Related Questions