Extract a list of files using unzip command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extract a list of files using unzip command
# 1  
Old 03-31-2014
Extract a list of files using unzip command

Hi all,
this is my first and i can't speak english well, so please be kind !

Here is my problem :
I want to unzip a list of .zip files stored in one directory, so I though about using that :
Code:
unzip '*.zip'

Thing is that all of my zipped folders contain a file with the unique same name : Doc.kml
eg : zipfile1.zip --> Doc.kml
zipfile2.zip --> Doc.kml
zipfileAB.zip --> Doc.kml
So, every unzipping process erase the precedent one...

What I want to do is unzipping all my files (zipfile1.zip,...) by mentionning the name of the unzipped zile (eg not Doc.kml but zipfiles.kml, zipfile2.kml, etc...)

I hope you got what I meant
Thanks for help !!

Rems
# 2  
Old 03-31-2014
From man unzip:

Code:
       -n     never overwrite existing files.  If a file already exists,  skip
              the extraction of that file without prompting.  By default unzip
              queries before extracting any file that already exists; the user
              may  choose  to  overwrite  only the current file, overwrite all
              files, skip extraction of the current file, skip  extraction  of
              all existing files, or rename the current file.

# 3  
Old 03-31-2014
thanks, I had noticed this.
But, unless typing manually the file name (for hundreds of files!), is it possible to do it more automatically?
I thought using a loop but I don't how to script it
# 4  
Old 03-31-2014
How would it know what filenames you wanted, from which file? Do you have a list?
# 5  
Old 03-31-2014
here a quote of my terminal :

Archive: STR_SUB.zip
replace DOC.kml? [y]es, [n]o, [A]ll, [N]one, [r]ename: r
new name: STR_SUB.kml
inflating: STR_SUB.kml

Archive: ATC.zip
replace DOC.kml? [y]es, [n]o, [A]ll, [N]one, [r]ename: r
new name: ATC.kml
inflating: ATC.kml

Explaining it with words : both zipped files STR_SUB.zip and ATC.zip contain a file named DOC.kml.
When asking replace "DOC.kml?" I type "r" then the name of my zipped files + .kml (eg : ATC + . kml)

Why wouldn't it be possible to do it automatically since I got a question for each zipfile using the name of the archive ?

example : something that could copy the filename ATC in ATC.zip and paste it into ATC.kml while extracting shall be possible, right?

Maybe the unzip function mey not be appropriate to do such a thing?!
# 6  
Old 03-31-2014
Quote:
Originally Posted by remissssss
thanks, I had noticed this.
But, unless typing manually the file name (for hundreds of files!), is it possible to do it more automatically?
Don't know which version of "unzip" you are using, But you could try the "-B" modifier:
Unzip multiple files. Linux | Compmiscellanea.com
UNZIP
# 7  
Old 03-31-2014
Something like (just a hint, remember to try it always in a backup directoy copied from the original):
Code:
for i in $( ls -1 *.zip) ; do unzip $i; $k=$(basename -s kml $i); mv Doc.kml $k.kml ; done

This User Gave Thanks to zzgfont For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unzip all the files with subdirectories present and append a part of string from the main .zip files

Hi frnds, My requirement is I have a zip file with name say eg: test_ABC_UH_ccde2a_awdeaea_20150422.zip within that there are subdirectories on each directory we again have .zip files and in that we have files like mama20150422.gz and so on. Iam in need of a bash script so that it unzips... (0 Replies)
Discussion started by: Ravi Kishore
0 Replies

2. UNIX for Dummies Questions & Answers

7z command for files larger than 4GB ( unzip doesn't work)

My unzip command doesn't work for files that are greater than 4GB. Consider my file name is unzip -p -a filename.zip, the command doesn't work since the size of the file is larger. I need to know the corresponding 7z command for the same. This is my Unix shell script program: if then ... (14 Replies)
Discussion started by: chandraprakash
14 Replies

3. UNIX for Dummies Questions & Answers

Extract .zip file without using unzip,tar

Hi, Need to extract a file containing multiple .txt files without using tar/unzip as they are not available (1 Reply)
Discussion started by: santoshdrkr
1 Replies

4. Shell Programming and Scripting

Extract few content from a huge list of files

I have a huge list of files (about 300,000) which have a pattern like this. .I 1 .U 87049087 .S Am J Emerg .M Allied Health Personnel/*; Electric Countershock/*; .T Refibrillation managed by EMT-Ds: .P ARTICLE. .W Some patients converted from ventricular fibrillation to organized... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

5. Shell Programming and Scripting

Single command - unzip files from a tar command

I have a tar file that contains multiple .Z files. Hence I need to issue a tar command followed by a gzip command to fully extract the files. How do I do it in a single command? What I'm doing now is tar xvf a.tar (this will output 1.Z and 2.Z) gzip -d *.Z (to extract 1.Z and 2.Z) (9 Replies)
Discussion started by: ericlim
9 Replies

6. Solaris

Command to list or view the files in .pkg (solaris) and how to extract without installing

In Linux for .rpm we can list or view the files using the command rpm -qpl <file.rpm> and to extract, the command is rpm2cpio <file.rpm> | cpio -idvh I would like to know the commands which has same functionality as above for solaris ( .pkg) Thanks in Advance (5 Replies)
Discussion started by: frintocf
5 Replies

7. Shell Programming and Scripting

How to Unzip a file using unzip utility for files zipped without zip utility ?

Hi, I need to zip/compress a data file and send to a vendor. The vendor does have only unzip utility and can accept only .ZIP files. I do not have zip utility in my server. How do I zip/compress the file so that it can be deflated using unzip command ? I tried gzip & compress commands, but... (1 Reply)
Discussion started by: Sabari Nath S
1 Replies

8. Shell Programming and Scripting

Shell script or command help to extract specific contents from a long list of content

Hi, I got a long list of contents: >sequence_1 ASSSSSSSSSSSDDDDDDDDDDDCCCCCCC ASDSFDFFDFDFFWERERERERFSDFESFSFD >sequence_2 ASDFDFDFFDDFFDFDSFDSFDFSDFSDFDSFASDSADSADASD ASDFFDFDFASFASFASFAFSFFSDASFASFASFAFS >sequence_3 VEDFGSDGSDGSDGSDGSDGSDGSDG dDFSDFSDFSDFSDFSDFSDFSDFSDF... (2 Replies)
Discussion started by: patrick87
2 Replies

9. UNIX for Dummies Questions & Answers

unzip .zip file and list the files included in the .zip archive

Hello, I am trying to return the name of the resulting file from a .zip archive file using unix unzip command. unzip c07212007.cef7081.zip Archive: c07212007.cef7081.zip SecureZIP for z/OS by PKWARE inflating: CEP/CEM7080/PPVBILL/PASS/G0063V00 I used the following command to unzip in... (5 Replies)
Discussion started by: oracledev
5 Replies

10. UNIX for Advanced & Expert Users

how to unzip and extract tar file in single command

In order to save diskspace and avoid of disk full during unzip then extract the tar file is there any tar unzip command would unzip and extract tar at the same time (test123.tar.gz) thank in advance (6 Replies)
Discussion started by: darkrainbow
6 Replies
Login or Register to Ask a Question