Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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/zipArchiveFile20110808.zip 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/zipArchiveFile20110809.zip 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
1  
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
add comment

migrated from stackoverflow.com Aug 20 '11 at 23:16

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

2 Answers

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
      /path/to/specific/individual/files/myfiles2011\*.txt 
      -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
add comment

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
1  
Just a head's up, he's using RedHat/Unix (hence the tags), not Windows. :) –  Kruug Jan 25 '13 at 0:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.