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.

My directory structure is as follows:

application
├── CV
│   └── CV.pdf
├── Cover_letter
│   └── Cover_letter.pdf
├── Transcripts
│   ├── BSC.pdf
│   └── MSC.pdf
└── references
    ├── ref1.pdf
    └── ref2.pdf

How do I zip these 7 PDF files from terminal so that I'll get an application.zip file, and if I extract it again all files land in just one folder?

share|improve this question

2 Answers 2

Zip (w/subdirs): zip -r {myzip.zip} application

Extract (excluding org. dir structure): unzip -d {destination}

share|improve this answer
    
-1, that doesn't achieve what the OP wants. Compressing the whole application folder will result in the same directory structure being extracted, and not all 7 PDFs in one folder. –  slhck Jul 28 '13 at 7:32

Use the -j (junk names) option to have zip remove the absolute/relative path of each file added, and only add it by its name. In the most simple case, where your application folder only contains PDF files apart from the directories, use this:

zip -jr application.zip application/

If you have various files, you need to filter them and add them one-by-one, so for example, do this:

find application -type f -name '*.pdf' -exec zip -j application.zip {} \;

This will add all PDF files in the application directory by their basename only, to:

adding: Cover_letter.pdf (stored 0%)
adding: CV.pdf (stored 0%)
adding: ref1.pdf (stored 0%)
adding: ref2.pdf (stored 0%)
adding: BSC.pdf (stored 0%)
adding: MSC.pdf (stored 0%)
share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.