Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to unzip individual files. These files have a .txt extension. These files also live within multiple zipped files. Here is the command I'm trying to use.

unzip -jn /path/to/zipped/files/zipArchiveFile2011\*.zip /path/to/specific/individual/files/myfiles2011*.txt -d /path/to/home/directory/for/extract/

From my understanding, the -j option excludes directories and will extract only the txt files The -n option will not overwrite a file if it has already been extracted. I've also learned that the forward slash in /path/to/zipped/files/zipArchiveFile2011\*.zip is necessary to escape the wildcard (*) character.

Here is sample of error messages I'm coming accross:

Archive: /path/to/zipped/files/ caution: filename not matched: /path/to/specific/individual/files/myfiles20110807.txt caution: filename not matched: /path/to/specific/individual/files/myfiles20110808.txt Archive: /path/to/zipped/files/ caution: filename not matched: /path/to/specific/individual/files/myfiles20110810.txt caution: filename not matched: /path/to/specific/individual/files/myfiles20110809.txt

I feel that I'm missing something very simple. I've tried using single quotes (') and double quotes (") around directory paths. But no luck.

share|improve this question

migrated from Aug 20 '11 at 23:16

This question came from our site for professional and enthusiast programmers.

Simplfy your problem to get extracting from 1 file working, i.e. remove the star in the first, replace it with the fully qualified path/to/UniqFileName AND then quote any remaining * chars as you indicated (\*). You do want to extract 1 or more files matching the second pattern .../individual/files/... from the archive, right? When you understand how that is working, then you can figure out how to use shell wildcards to create a list of files that unzip will process all at once – shellter Aug 11 '11 at 23:18

I think you should also quote the * in the list of files. The command should looks something like that:

unzip -jn /path/to/zipped/files/zipArchiveFile2011\*.zip
      -d /path/to/home/directory/for/extract/

If doesn't quote the second * bash expands it and place the files names. You can check the value which is passed to command by using echo:

echo /path/to/specific/individual/files/myfiles2011*.txt
share|improve this answer

For unzip command with range expression in filename, we need to escape both the range format and the wildcard in target filename, e.g. to unzip files with txt extension in, ... into folder txt_pool, we should issue command like this:

unzip -jn order071\[0-5].zip \*.txt -d txt_pool
share|improve this answer

Did you try WinRar?

Simply create a batch file named unrar.bat

c: md \unrar cd \unrar "C:\Program Files (x86)\WinRAR\unrar.exe" e %1 start c:\unrar

Now right click any .zip file and choose Open with... Browse that unrar.bat

I hope you see the idea.

P.S: You can create a shotcut at taskbar/quicklaunch and then drag files over the icon of .bat file -instead of right clicking...

If you don't wan the directories, make a search at the end with the *.txt mask. All txt files will be listed, now you can easily select/cut/paste them.

share|improve this answer
Just a head's up, he's using RedHat/Unix (hence the tags), not Windows. :) – Kruug Jan 25 '13 at 0:42

You must log in to answer this question.