Reputation: 1290
For a first time I need to create an .sh
for do something. My aim is to unzip a lot of zip folders, so I've wrote the script below:
for zipfiles in /downloads/*.zip; do unzip $zipfiles; done
I can unzip all but I noticed that there are some files with the same name and typing y
I can ultimate the process.
There is a way to extract only files with a specific extension, like .docx
, instead of the entire zip folder? I'm absolutely sure that there aren't .docx
with the same name.
Upvotes: 0
Views: 748
Reputation: 630
try this one, it can be useful for your purpose.
for zipfiles in /downloads/*.zip; do unzip -xo "$zipfiles" '*.docx' ; done
by this option overwrite files WITHOUT prompting.
Upvotes: 0
Reputation: 75478
You can specify a pattern:
for zipfiles in /downloads/*.zip; do unzip "$zipfiles" '*.docx'; done
Tested to work with UnZip 6.00
.
You can also specify the -x
option to exclude.
Upvotes: 2