Command to zip a bunch of files

Chitchat about x² / 2X products

Moderators: fgagnon, nikos, Site Mods

Post Reply
User avatar
kdaube
Member
Member
Posts: 24
Joined: 2014 Jun 05, 16:42

Command to zip a bunch of files

Post by kdaube »

Dear experts,

I tried to create a command to ZIP selected file names. Model was http://forum.zabkat.com/viewtopic.php?f=22&t=7278

Code: Select all

>> "H:\Utilities\7-Zip\7z.exe" a -tzip "$I\$?.zip" "$A\"
  • I select some files in the left pane
  • hit the button with the command,
  • be prompted for the ZIP name
  • and get an empty ZIP in the right pane with the proper name
  1. What is the final \ in the model good for?
  2. $A seems to create a list of files with NL as separator, not with commas as I get it with ALT+C
  3. How to get this command working as intended?
I'm newbee with Xplorer, so at first i really browsed through the manual and looked for samples...
Thanks for any help
Klaus Daube
User avatar
nikos
Site Admin
Site Admin
Posts: 15791
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Re: Command to zip a bunch of files

Post by nikos »

instead of "$A\" use $A without quotes. This selects all the filenames
also you should use a single > instead of >>, what are you trying to do? zip each file separately or all together?
User avatar
kdaube
Member
Member
Posts: 24
Joined: 2014 Jun 05, 16:42

Re: Command to zip a bunch of files

Post by kdaube »

Nikos,

I want to zip the selected files and folders togetzer into one ZIP file.
With

Code: Select all

> "H:\Utilities\7-Zip\7z.exe" a -tzip "$I\$?.zip" "$A"
I get the same results as before: empty zip file.
User avatar
nikos
Site Admin
Site Admin
Posts: 15791
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Re: Command to zip a bunch of files

Post by nikos »

to be honest i am not familiar with the command line options of 7zip so you could have a problem with the command line arguments.
User avatar
kdaube
Member
Member
Posts: 24
Joined: 2014 Jun 05, 16:42

Re: Command to zip a bunch of files

Post by kdaube »

Nikos, I have an AHK script which does similar work:

Code: Select all

zipper   = H:\Utilities\7-Zip\7z.exe                         ; cmd line version
zipFile = Inst-FM11-toolbars-en.zip                          ; expected result
zipParms = a %zipFile% InstallETB\  PrepInstall-etb-en.exe   ; put directory + file into ZIP
RunWait, %zipper% %zipParms%, , Hide                         ; run 7Zip
There is no -tzip here, but this is a saftey measure i put in: make a ZIP archive, not RAR or else. I could leave it out.
What You see here is that just a list of files to be zipped is provided at the end of the parameter list:

Code: Select all

InstallETB\  PrepInstall-etb-en.exe
The first is a directory, the second a file.
mhm, just now I see that there is no comma between them, and if $A privides the comma then there is the problem.
Anyhow, if there is no direct solution to my desire, then this is an option:
  • get the list of iles into the clipboard with ALT+C
  • Have an AHK script which takes this list and has a prompt for the output ZIP
  • Run this AHK script as a command from the ZIP button
Kilmatead
Platinum Member
Platinum Member
Posts: 4578
Joined: 2008 Sep 30, 06:52
Location: Dublin

Re: Command to zip a bunch of files

Post by Kilmatead »

kdaube wrote:

Code: Select all

> "H:\Utilities\7-Zip\7z.exe" a -tzip "$I\$?.zip" "$A"
I get the same results as before: empty zip file.
As Nikos said, remove the quotes from around $A

Code: Select all

... "$I\$?.zip" $A
User avatar
kdaube
Member
Member
Posts: 24
Joined: 2014 Jun 05, 16:42

Re: Command to zip a bunch of files

Post by kdaube »

Thanks Kilmatead,

Had not completely understood - now it works excellent! Even with those darn file names containing blanks.

Subject closed
Post Reply