Author Topic: Compress (zip) Folder with todays date and time in the filename  (Read 27351 times)

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4484
    • View Profile
    • Multi Commander
Compress a predefined folder into a predefined file.

Command Type : Custom Command

MC.Filesystem.PackFiles FILES="D:\Projects\Documents\*.*" METHOD="Zip" TARGET="D:\${date:yyyy-MM-dd}_${time:HH:mm}-Documents.zip"

Pack everything in "D:\Projects\Documents" into a file name, that will be named "D:\2011-08-20_1821-Documents.zip"

Ulfhednar

  • Contributor
  • VIP Member
  • *****
  • Posts: 514
    • View Profile
I wish to make an unpack button, first select archives then extract to parent & overwrite pre-existing files options enabled.
I wondered if I can use some MultiScript to do this.
Are there any MS commands & switches for this that would control/over-ride the Unpack dialogs default behaviour?

Something like this?
Code: [Select]
MC.Explorer.Select  FILTER="*.rar *.zip"
MC.Filesystem.UnpackFiles FILES="${sourcepath}" TARGET="${sourcepath}"

Which obviously doesn't work   ;D

Thanks

Jungle

  • Contributor
  • VIP Member
  • *****
  • Posts: 555
  • Old Skull
    • View Profile
Don't know whether it is possible to disable overwrite confirmation via MC.XChangeSettings as i haven't found list of supported settings.
So as a workaround the following could be done:
1. Disable copy confirmation
2. Unpack to a temp dir
3. Copy to target
4. Enable confirmation

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4484
    • View Profile
    • Multi Commander
No that is currently not possible. Script can not modify the copy parameters, it is planned but it a bit complex to add.

However IF you know the file name of the file you want form inside the zip you can use the MultiScript function CopyFile(..).
(Since zip is a virtual filesystem inside MC, most file system function handles zip files as it is a folder, (with some limitations))

Code: [Select]
@var $srcFile = "G:\\Test\\Test.zip\\Readme.txt";
@var $targetFolder = "G:\\Test\\Test\\";
CopyFile($targetFolder, $srcFile, "NODIALOG, OVERWRITE_ALL");


Ulfhednar

  • Contributor
  • VIP Member
  • *****
  • Posts: 514
    • View Profile
Thanks for the replies.  :)
Will something like "MC.Filesystem.UnpackFiles" also be developed as a script option for the future?

Currently my quickest workaround is to open the archive in one tab & have the opposite pane set as the destination folder.  'Copy' will 'extract' to that dir, then I can delete the source archive.

I guess it may be best to invoke an external app.  Maybe I can use a button to run a cmd-line for 7zip or something.

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4484
    • View Profile
    • Multi Commander
MC.Filesystem.Unpack Is already there

You can also copy using the Unpack fileoperation plugin. or browse into the zip as it was a folder and copy.

Ulfhednar

  • Contributor
  • VIP Member
  • *****
  • Posts: 514
    • View Profile
OK, I had just guessed that might be the command given MC.Filesystem.PackFiles
Do you intend to add switches to that command, or are they also there already?
Be helpful to have the Unpack & Pack script variables in this thread to keep us going until the script docs get an update.  (& I'm guessing you have added quite a few scripting commands in the last few builds)

Going OT
I tried this on a button, & got a Failed to find file msg.
Code: [Select]
"C:\Program Files\7-Zip\7z.exe x *.zip -aoa"Its unclear to me if this is the exe or the zip as 7Zip does accept a wildcard in the cmd-line.

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4484
    • View Profile
    • Multi Commander
The list of all the parameters are shown in the editor for a User Defined commands for "Custom Command" type

Ulfhednar

  • Contributor
  • VIP Member
  • *****
  • Posts: 514
    • View Profile
Thanks Mathias.

I tried a few variations but all I can do is invoke the native unpacker from a button, maybe I have forgotten how to do this  :-[
Using the custom commands dialog & one of the following strings -
Code: [Select]
MC.Filesystem.Unpack TARGET=${sourcepath} FILTER="*.rar" selecting a file then clicking the button makes a dialog flash up but does not work, I am missing something  ::)

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4484
    • View Profile
    • Multi Commander
Filter is for the files you unpack. So this should be *.* if you want to unpack all the files in the archive

Don't think you need to set it if it should unpack all

Ulfhednar

  • Contributor
  • VIP Member
  • *****
  • Posts: 514
    • View Profile
Re: Compress (zip) Folder with todays date and time in the filename
« Reply #10 on: May 07, 2014, 11:22:03 »
Thanks Mathias.
DoH! Looks like I mixed the FILE & the FILTER switch when trying to figure it out, wildcard for contents works...!   :D