Multi Commander Support Forum

Multi Commander => Script => Topic started by: Mathias (Author) on August 23, 2011, 18:50:35

Title: Compress (zip) Folder with todays date and time in the filename
Post by: Mathias (Author) on August 23, 2011, 18:50:35
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"
Title: Re: Compress (zip) Folder with todays date and time in the filename
Post by: Ulfhednar on May 02, 2014, 14:54:00
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
Title: Re: Compress (zip) Folder with todays date and time in the filename
Post by: Jungle on May 04, 2014, 08:10:17
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
Title: Re: Compress (zip) Folder with todays date and time in the filename
Post by: Mathias (Author) on May 04, 2014, 10:23:18
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");

Title: Re: Compress (zip) Folder with todays date and time in the filename
Post by: Ulfhednar on May 05, 2014, 13:19:06
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.
Title: Re: Compress (zip) Folder with todays date and time in the filename
Post by: Mathias (Author) on May 05, 2014, 13:55:36
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.
Title: Re: Compress (zip) Folder with todays date and time in the filename
Post by: Ulfhednar on May 05, 2014, 16:32:34
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.
Title: Re: Compress (zip) Folder with todays date and time in the filename
Post by: Mathias (Author) on May 05, 2014, 17:05:29
The list of all the parameters are shown in the editor for a User Defined commands for "Custom Command" type
Title: Re: Compress (zip) Folder with todays date and time in the filename
Post by: Ulfhednar on May 06, 2014, 13:07:03
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  ::)
Title: Re: Compress (zip) Folder with todays date and time in the filename
Post by: Mathias (Author) on May 06, 2014, 13:50:33
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
Title: Re: Compress (zip) Folder with todays date and time in the filename
Post by: Ulfhednar 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