Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'm trying to compress 5 files into an Archive.zip

Selecting the 5 files and using Finder's built in Compress feature, the resulting Archive.zip contains a root level folder name "Archive", which in turn contains those 5 files.

How do I create an Archive.zip that unzips those 5 files without any containing folder?

share|improve this question
1  
I could be wrong, but I think this is a "safety measure" (in the loosest sense of the word). So that if you archived, say, a hundred files in the manner you suggest, if an unsuspecting person unarchived them they would never get hundreds of files created accidentally in the folder they uncompressed it in, if they forgot to create a new one. –  binarybob May 13 '12 at 16:17
    
I can see the virtue in that safety measure, but logic dictates that the safety measure should be enabled at the extraction end. It would be easy for the Archive Utility program to always extract files into a folder. Having the safety mechanism kick in at the compression end is just silly and irritating. –  izolate May 13 '12 at 21:22
    
That's already how it's working (the Archive folder gets created on extraction, not on compressing). Even better, if you compress a single folder (aka your archive contains a single root folder with stuff beneath), it doesn't create an additional root folder. –  patrix May 14 '12 at 5:47
add comment

4 Answers

up vote 2 down vote accepted

The resulting Archive.zip does not contain a root level folder name "Archive". It's only when you uncompress it by double-clicking that this folder is created. To confirm, try unzip -tv Archive.zip. So it's Archive Utility that is creating this folder when you uncompress.

share|improve this answer
    
You were correct. Thanks for that terminal snippet. I'd give you an upvote, but I don't have enough rep. –  izolate May 14 '12 at 8:08
add comment

EDIT: The process that you are talking about would appear to be new, since I know it worked as I described it in the last 2 years. So I'm guessing it changed either in Lion or Snow Leopard, Lion if I were to hazard a guess.

I don't have a workaround as yet but I have replicated that functionality. ~~~~~~~~~~~

The built in Compress feature will add All Folders and Files from the selection downwards, including the first selected item, even it it is a folder.

Two options:

  1. Don't use the built in functionality and use a 3rd party archiving tool that has more control
  2. Select the five files inside the folder (but not the folder itself), then ctrl+click (right click) and then select Compress
share|improve this answer
1  
I think you misunderstood what I was saying. Say I have 5 files on my desktop. When I select these 5 files and right click > compress, it automatically puts them all in a folder called "Archive" and compresses this new containing Archive folder, resulting in Archive.zip. I need to figure out how to stop that. I've tried a couple of 3rd party tools and they seem to just be GUIs for Apple's own compression mechanism. –  izolate May 13 '12 at 14:29
    
So you want the 5 selected files to become 5 individual .zips? –  John Rygielski May 13 '12 at 18:51
    
No - I want the 5 files inside one .zip file. The .zip file should only contain the 5 files. The .zip file currently contains 6 files: 1 directory and my 5 files inside that directory. I need to figure out how to remove that directory folder inside the .zip and move the 5 files up one level. Does that make it clearer? –  izolate May 13 '12 at 21:16
add comment

I have some software loaded on sites where they upload a zip file. The software unzips the individual files to its generated directory and points the image compression and resizing to that new directory. It worked great till recently when all of a sudden when we compressed files the zip extracted to an archive folder on the server, the software doesn't work on folders it works on image files. I tried everything and numerous archive apps, I then tried Hamster Archiver. It worked for me, no more does it extract to a new folder. It might help you. Good luck

share|improve this answer
add comment

The Apple GUI method is clean and neat for most folks to use, and the enclosing Archive folder prevents the inadvertent overwriting of files. In your case, you'll have to use the command line in Terminal to do what you want using the commands zip and unzip.

Read the man pages for zip and unzip for a fuller appreciation of what is possible.

Step 1: zip up the files

• Run Terminal

• execute: zip /path/out_filename /path/in_filename

You can select multiple files (from different directories & disks, too) and drag from the Finder GUI into the Terminal window. Terminal will expand /path/ for you in this case.

Ex: zip ~/Desktop/all_zipped_up ~/Desktop/zip_me_up.txt ~/Documents/zip_me_up2.txt

This creates all_zipped_up.zip to the Desktop in this example.

Step 2: unzip the files

The key to unzipping without creating an enclosing folder is to use the -j switch:

• Run Terminal

• execute: unzip -j /path/out_filename

• The expanded file(s) will appear at the same path as the source .zip file. You can also use the -d switch to expand into another path. According to the man page, the -d switch can go almost anywhere in the command line. I put it at the end because it is a logical place to put it.

Example to expand to same path as the original archive:

unzip -j ~/Desktop/all_zipped_up.zip

Example to expand to alternate path:

unzip -j ~/Desktop/all_zipped_up.zip -d ~/Desktop/New_Folder

share|improve this answer
add comment

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.