Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 04, 2016, 10:22:03 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: IDEA: zip all main sub-folders at once  (Read 11150 times)

jity2

  • Charter Member
  • Joined in 2006
  • ***
  • default avatar
  • Posts: 98
    • View Profile
    • Donate to Member
IDEA: zip all main sub-folders at once
« on: August 04, 2006, 04:09:18 PM »
Hello,

I am using the great freeware unziplify (http://www.silverban...m/tabdown/unziplify/) in order to unzip with only one click all zipped folders inside any zip file contained into a main folder.
I would like to have a software which would do quite similarly the opposite!

Example:
I have this mainfolder :
c:\main_folder\

It contains several sub-folders (and each sub-folders contain many files and folders which don't need to be zipped separately) :
c:\main_folder\Aafolder
c:\main_folder\Abfolder
...
c:\main_folder\ZZfolder

I would like to just have to click on a context menu buton (right mouse click) on the folder "c:\main_folder\", so it will zip all the first sub-folders at once :
c:\main_folder\Aafolder.zip
c:\main_folder\Abfolder.zip
...
c:\main_folder\Zzfolder.zip


Note: I am using currently Powerarchiver as a zip program.

Thanks in advance for your help ;)

See ya
Jity
EDIT: The solution is in the bottom messages (use a free Autohotkey script and buy Winrar : see http://www.donationc...57.msg33048#msg33048)!
« Last Edit: August 06, 2006, 02:51:37 AM by jity2 »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,406
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: IDEA: zip all main sub-folders at once
« Reply #1 on: August 04, 2006, 04:50:09 PM »
Try my very own Drag+Drop Robot:
http://www.donationc.../dragdrop/index.html

The demo movie shows how to do (almost) exactly this:
http://www.donationc...agDrop/DragDrop.html

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,406
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: IDEA: zip all main sub-folders at once
« Reply #2 on: August 04, 2006, 04:51:14 PM »
ps. the still-in-progress program we are working on called "Context Menu Commander" would be ideal for adding such a conext-menu to your right-click options..

jity2

  • Charter Member
  • Joined in 2006
  • ***
  • default avatar
  • Posts: 98
    • View Profile
    • Donate to Member
Re: IDEA: zip all main sub-folders at once
« Reply #3 on: August 04, 2006, 06:28:14 PM »
Hello Mouser,

Wow many thanks! ;) Alas I tried but I was unsuccessfull! ;(

I have tried with the command line program made by the powerarchiver team.
It is called PACL (pacl401.exe)

I add this in the command line :
C:\PACL\PACOMP.EXE -a -c1 -P -k "%2.zip" "%2"

and set "allow dropped folders"

I add my folder "C:\test\91" in the folder queue.

Press start.

The ouput says it is ok. But if I use the option "redirected", I have the error :
Archive: C:\test\91.zip
  preparing to compress...
   *** WARNING: Nothing to add or update...


I am enclosing their text file manual , I hope you can be better than myself on this one! ;)

Apparently even my basic line is wrong! :
C:\PACL\PACOMP.EXE -a "%2.zip" "%2"

I have also tried unsuccesfully :
C:\Program Files\PowerArchiver\POWERARC.EXE -a -r "%2.zip" "%2"

Thanks in advance,
Jity
« Last Edit: August 04, 2006, 06:30:37 PM by jity2 »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,406
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: IDEA: zip all main sub-folders at once
« Reply #4 on: August 04, 2006, 06:31:59 PM »
you dont want %2 you want %A

jity2

  • Charter Member
  • Joined in 2006
  • ***
  • default avatar
  • Posts: 98
    • View Profile
    • Donate to Member
Re: IDEA: zip all main sub-folders at once
« Reply #5 on: August 04, 2006, 06:41:34 PM »
Thanks Mouser for the fast reply. I appreciated. ;)
It seemed to worked once, the files in my subfolders were zipped, but not the subfolders.
Then it stopped working the next time!
Maybe it is me or that it is too late for me now! ;(
Thanks again ;)

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,029
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: IDEA: zip all main sub-folders at once
« Reply #6 on: August 04, 2006, 11:48:45 PM »
Jity2, you might need some command-line argument to your compressor to make it include subfolders.

Anyway, it should be a relatively trivial task to do what ou want; one of the AutoHotKey people could probably do it insanely fast :)
- carpe noctem

jity2

  • Charter Member
  • Joined in 2006
  • ***
  • default avatar
  • Posts: 98
    • View Profile
    • Donate to Member
Re: IDEA: zip all main sub-folders at once
« Reply #7 on: August 05, 2006, 04:40:31 AM »
Dear all,

I finally found a solution. ;-)

After trying for 2 hours I gave up PCAL (too simple zip program contrary to Powerarchiver after reading their forum) with Drag and Drop Robot (sorry Mouser the command lines even after your great help were too complex for me)!

Thanks to f0dder, I tried to use the great shareware MacroMagic instead (with Powerarchiver).
I joining the macros I have created (in total this simple thing took me around 3 hours as there were a lot of simple tricks to use).
First download the joined txt files, rename them into ".key". Load them into MacroMagic.
Now all is working ok you just have to be inside your main folder, count manually the number of folders to zip, make the change in "zip_main_folders_Add_here_inside_N-1_repeat.key".
Example: in total you have 8 folders, so you have to change this key "zip_main_folders_Add_here_inside_N-1_repeat.key" into 7 repeats (=8-1).  Then go into your main folder and I am using the keyboard keys CTRL + ALT + O to do the job.  ;-)

Thanks again. ;-)
See ya
Jity

wr975

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 369
    • View Profile
    • Donate to Member
Re: IDEA: zip all main sub-folders at once
« Reply #8 on: August 05, 2006, 06:29:21 AM »
It's no right-click solution, but works fine without need to count folders or change a macro. Perhaps you'll like it.


See attachment to this post for a compiled exe

or

1. Save the code as "whatever.ahk" script file
2. Download and install Autohotkey (freeware), then you can double click the script


FileSelectFolder,SourcePath,,0,Select Source Folder
If SourcePath =
ExitApp

FileSelectFolder,TargetPath,*%SourcePath%,0,Select Target Folder
If TargetPath =
ExitApp

Loop,%SourcePath%\*.*,2,0
RunWait,c:\PACL\PACOMP.exe -a -r -p "%TargetPath%\%A_LoopFileName%.zip" "%A_LoopFileFullPath%\*.*"

Just for information: PACOMP won't add empty folders (folders without files). So if you test it with empty folders, don't be surprised if it won't work.
« Last Edit: August 05, 2006, 06:36:37 AM by wr975 »

jity2

  • Charter Member
  • Joined in 2006
  • ***
  • default avatar
  • Posts: 98
    • View Profile
    • Donate to Member
Re: IDEA: zip all main sub-folders at once
« Reply #9 on: August 05, 2006, 08:46:46 AM »
Thank you Wr975. Your help is much appreciated. ;)

Alas as I wrote I prefer not to use PCAL afterall. I prefer to be sure of what my zip program does, so I continue to use Powerarchiver (which I have tested a lot for my data).
Futhermore my process also can handle the empty folders, i.e., zipping nothing! ;)

The big difference for me is the handling of accents (I am french!) so "é" does not become "Û"!

Anyway I have tried your suggestion (BTW, I could not download your compiled exe file maybe because it is an exe file forbideen on this forum, but I followed your guidelines and it worked ok).
Here is the comparison :

It seems to me that your script is faster (maybe 20% rought guess) to do the compressing job.

But mine may be better handling odds files and caracters (accents) contained inside small html folders I guess : see the slight size difference (see attached image) at the end.

Thanks again, ;)
See ya,
Jity

wr975

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 369
    • View Profile
    • Donate to Member
Re: IDEA: zip all main sub-folders at once
« Reply #10 on: August 05, 2006, 11:59:55 AM »
I've just used PowerArchiver Commandline (PACL) because you wrote, you're using PowerArchiver.  ;)

I had a look at the help file... the main program supports very few parameters and tells to use PACL for more options. However, PACL has at least one bug (does not support accents), so the Autohotkey script won't work with PowerArchiver.

A solution would be using Winrar. It supports a lot of command line parameters. I've tested the script using Winrar and it'll compress empty folders and won't change accents.

If you want to give Winrar a try (the shareware never expires), you just need to change the last line of the script.

RunWait,c:\Program Files\WinRar\WinRar.exe a -r -ep1 -m5 "%TargetPath%\%A_LoopFileName%.zip" "%A_LoopFileFullPath%\*.*"

-m5 = compression ratio (0 to 5). Change it to -m0 for no compression... -m3 standard compression... -m5 max compression

To create RAR files (slower, but no file limit and better compression) change ".zip" to ".rar".

jity2

  • Charter Member
  • Joined in 2006
  • ***
  • default avatar
  • Posts: 98
    • View Profile
    • Donate to Member
Re: IDEA: zip all main sub-folders at once
« Reply #11 on: August 05, 2006, 01:21:21 PM »
Hi Wr975,

Guess what? I tried again my solution with MacroMagic and it ...failed! ;-(

So I tried winzip with your code it worked but I couldn't use unziplifly to extract the data! ;-(
Then I tried the free zip program listed here
http://www.donationc...hiveTools/index.html
but 7z supported unicode files but shoudln't work with unziplifly.

Then I thought to use winrar and your were giving me the solution for it! Wow! I really appreciated! ;-)


The only problem that I have with winrar is that even if I click on the background buton, the Diagnostic message window is displayed each time a folder is empty! So I have to click manually on teh "close" buton so your code continue to do its work!

"!   C:\New.zip: No files to add"

I have tried to include "-ed" or "-ilog" after "a" in your code alas without success!

   RunWait,c:\Program Files\WinRar\WinRar.exe a -r -ep1 -m3 "%TargetPath%\%A_LoopFileName%.zip" "%A_LoopFileFullPath%\*.*"

BTW, IMHO here is the anwser for the accent problem for PACL:
http://www.izarc.org/
"I have received many emails from people that have problems with archives containing files with non English filenames. Also some peoples ask me for x64 version of IZArc.
Unfortunately I can’t help them because IZArc is created using Borland’s Delphi but it doesn’t support Unicode names and can compile only x86 (32-bit) applications.
That’s why I decided to rewrite IZArc using Microsoft’s Visual Studio 2005 (Express Editions are not applicable!!!).
To be able to do this I have to purchase a licensed copy of VS 2005 and probably some additional components. "


I have bought winrar anyway (using the discount available from this great community). ;-)

Thanks again ;-)
Jity
« Last Edit: August 05, 2006, 03:34:41 PM by jity2 »

wr975

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 369
    • View Profile
    • Donate to Member
Re: IDEA: zip all main sub-folders at once
« Reply #12 on: August 05, 2006, 05:26:55 PM »
Quote
7z supported unicode
I experimented a while ago with 7zip command line. It was difficult to configure and didn't support folder names with accents. I wasted hours trying. Then I tried it with Winrar and got it working in 5 minutes. This was the day I bought Winrar. :up:

Quote
The only problem that I have with winrar is that even if I click on the background buton, the Diagnostic message window is displayed each time a folder is empty! So I have to click manually on teh "close" buton so your code continue to do its work!

"!   C:\New.zip: No files to add"

I have tried to include "-ed" or "-ilog" after "a" in your code alas without success!

If your folder structure is like...

C:\test\aa\file.txt
C:\test\ab\subfolder\file.txt
c:\test\ac

you'll get two files:
aa.zip, containing "file.txt"
ab.zip, containing "subfolder\file.txt"

since there's nothing in "ac" there's no point creating an archive. The message "No files to add" is just information, so you know why there's no archive. If you'd create an empty subfolder in "ac", you'll get your "ac.zip" file with the one subfolder.

The error appears only if you create .zip files. If you'd create .rar files, it won't appear. I'm not sure if this is a bug or a feature. Who'd try to archive empty folders anyway.  :D

I tried the switch -inul and it works: No more error messages. I'm not sure why it's not working on your side.  :huh:

RunWait,c:\Program Files\WinRar\winrar.exe a -r -ep1 -m0 -inul "%TargetPath%\%A_LoopFileName%.zip" "%A_LoopFileFullPath%\*.*"







[edited by mouser to add some blank space in code block so that it would display better]
« Last Edit: August 05, 2006, 06:45:29 PM by mouser »

jity2

  • Charter Member
  • Joined in 2006
  • ***
  • default avatar
  • Posts: 98
    • View Profile
    • Donate to Member
Re: IDEA: zip all main sub-folders at once
« Reply #13 on: August 05, 2006, 07:03:27 PM »
Hi wr975,

Thanks for the "-inul" confirmation, it is working now for me! ;-)
It was not working as I have added previously "-ed"  with "-inul" in the same line!
It seems to me that "-ed" is for rar files only!

After thinking of it, I prefer not to include "-inul" as if there was any important error (other than void folders), I would not know about it!
So I will manually removed the empty folders before running your great script! ;-)
(AHK forum suggest this. http://www.autohotke...viewtopic.php?t=3835 I have tried it but nothing loaded for me! Anyway, this seems too complex for me so I keep it simple!).

Thanks ;)
Jity
« Last Edit: August 06, 2006, 02:46:52 AM by jity2 »

wr975

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 369
    • View Profile
    • Donate to Member
Re: IDEA: zip all main sub-folders at once
« Reply #14 on: August 06, 2006, 01:26:16 AM »
Quote
So I will manually removed the empty folders before running your great script! ;-)

It's pretty basic. Anyone who reads AHK help could do such script. :)


I didn't do the script so you still had to do manual work. Kinda annoying. Here's a little extra code. Now the script will only archive folders, if there's at least 1 byte. Empty folders won't get archived, so no error message appears.

Replace the last two lines with this code

Loop,%SourcePath%\*.*,2,0
{
FolderSize = 0
Loop, %A_LoopFileFullPath%\*.*, , 1
FolderSize += %A_LoopFileSize%
If FolderSize >0
RunWait,c:\Program Files\WinRar\winrar.exe a -r -ep1 -m5 "%TargetPath%\%A_LoopFileName%.zip" "%A_LoopFileFullPath%\*.*"
}
« Last Edit: August 06, 2006, 01:29:02 AM by wr975 »

jity2

  • Charter Member
  • Joined in 2006
  • ***
  • default avatar
  • Posts: 98
    • View Profile
    • Donate to Member
Re: IDEA: zip all main sub-folders at once
« Reply #15 on: August 06, 2006, 02:45:55 AM »
Wow! Thanks wr975! ;)

I have tried to study AHK help files, but I am pretty sure I wouldn't have been able to find your solution (I tought there was something to do with "Fileremovedir" http://www.autohotke...om/docs/commands.htm
! Obviously this was not so easy!)

I am posting a summary of the full solution in my next message.
Thank you again ;)
Jity

jity2

  • Charter Member
  • Joined in 2006
  • ***
  • default avatar
  • Posts: 98
    • View Profile
    • Donate to Member
Re: IDEA: zip all main sub-folders at once
« Reply #16 on: August 06, 2006, 02:48:51 AM »
Here is a summary of the solution, thanks to wr975 ;)  :

1/ Buy winrar (forget Winzip, Powerarchiver or PCAL...) (you can use the discount available here http://www.donationc...hiveTools/index.html)
2/ Download and install Autohotkey (freeware http://www.autohotkey.com/), then you can double click the script
3/ Save the following code as "whatever.ahk" script file:
Code:
FileSelectFolder,SourcePath,,0,Select Source Folder
   If SourcePath =
      ExitApp

FileSelectFolder,TargetPath,*%SourcePath%,0,Select Target Folder
   If TargetPath =
      ExitApp

Loop,%SourcePath%\*.*,2,0
{
   FolderSize = 0
   Loop, %A_LoopFileFullPath%\*.*, , 1
      FolderSize += %A_LoopFileSize%
   If FolderSize >0
      RunWait,c:\Program Files\WinRar\WinRar.exe a -r -ep1 -m3 "%TargetPath%\%A_LoopFileName%.zip" "%A_LoopFileFullPath%\*.*"
}
Note: -m5 = compression ratio (0 to 5). Change it to -m0 for no compression... -m3 standard compression... -m5 max compression
You can also add "-inul" after "-m3" if you don't want any error to be reported by winrar.


Thanks again to all helpers, your help was much appreciated as I was waiting for about 2 years for such a thing! ;)
See ya,
Jity