Jump to content



Photo

Zip all files in many sub-directories

win7

  • Please log in to reply
19 replies to this topic

#16 OP Pedro3

Pedro3

    Neowinian

  • Joined: 02-August 04

Posted 12 June 2014 - 04:24

Sorry, had a lot of work lately.

 

I tried 

for /d %X in (*) do "C:\Program Files\7-Zip\7z.exe" a "%X.zip" "%X\"

 

But it's the same has doing WinZip (Put each file to separate archive). It compress the folder and not just the files inside of it.

 

I think like this works but the perfect solution was to zip just the files inside.

 

Thanks everyone for the help!




#17 OP Pedro3

Pedro3

    Neowinian

  • Joined: 02-August 04

Posted 14 June 2014 - 08:08

WinZip does it "automatically", just select the folders then the option "Put each File to separate archive". But, like I said, it compress the files inside the folder and the folder itself.

 

 

Don't know what happened, someone asked if this was possible to do automatically and I did answer, but the post is gone :wacko:



#18 +BudMan

BudMan

    Neowinian Senior

  • Tech Issues Solved: 96
  • Joined: 04-July 02
  • Location: Schaumburg, IL
  • OS: Win7, Vista, 2k3, 2k8, XP, Linux, FreeBSD, OSX, etc. etc.

Posted 15 June 2014 - 11:19

"I think like this works but the perfect solution was to zip just the files inside."

 

What??  Zip the files inside to what, individual zips???  How do you zip stuff inside a folder, but not the folder??



#19 OP Pedro3

Pedro3

    Neowinian

  • Joined: 02-August 04

Posted 15 June 2014 - 11:29

If you zip folder A1, when you unzip it, it shows the Folder A1 and it's contents. If you zip all the files inside Folder A1, then you unzip it, it'll show just the files that were inside Folder A1.

 

Example: Comic Books

 

Scan the comic book and put the .jpg inside a folder (B2), then zip B2. Most of the comic readers will read all the files inside B2, but others don't. If I select all the .jpg inside B2 and zip them, then all the Comic Readers will read the file.

 

Did I explain myself correctly?



#20 +BudMan

BudMan

    Neowinian Senior

  • Tech Issues Solved: 96
  • Joined: 04-July 02
  • Location: Schaumburg, IL
  • OS: Win7, Vista, 2k3, 2k8, XP, Linux, FreeBSD, OSX, etc. etc.

Posted 15 June 2014 - 12:31

so you don't want the path in the zip then..  That is easy enough to do if your in the folder the path will not be included with 7z - you would have to cd to each folder than run the command..  Makes the command a bit more complicated..  I would just use winrar if you need to get fancy..  Now rar can not create zip, but winrar can.  And you can call it from cmd line..  You will just get a gui popup showing progress when you run it.

 

So you want this

 

nopath.png

 

Vs with the 7z command I gave produces this for the same folder

 

withpath.png

 

Now if the folders have subfolders and you just don't want the base path this command works

 

for /d %X in (*) do "C:\Program Files\WinRAR\winrar.exe" a -ep1 -r "%X.zip" "%X\"

 

This will create zip with no base - so files in the root of the archive, but with subfolders listed..  If you don't have subfolders are don't want to zip them.

 

for /d %X in (*) do "C:\Program Files\WinRAR\winrar.exe" a -ep "%X.zip" "%X\"

 

But you will only get files that are in root of the folders..  I think the first one is the one your most after..  It can be done with 7zip as well - but you have to do a cd to each folder in your command.  Might be able to do something with pushd and popd to maintain where your at in the folder structure for zipping - but use of winrar is just easier because they have a switch to turn of path(s).

 

So for example the archive will not have a base folder, but any subfolders will be included..  Like this

 

nobasebutsub.png