Differences between revisions 6 and 14 (spanning 8 versions)
Revision 6 as of 2008-11-01 18:49:00
Size: 1341
Editor: anonymous
Comment:
Revision 14 as of 2017-02-16 19:22:55
Size: 1593
Editor: KaiJaeger
Comment:
Deletions are marked like this. Additions are marked like this.
Line 4: Line 4:
... here in Dyalog APL syntax ... here in Dyalog APL syntax.

([[ http://www.vector.org.uk/archive/v231/askzip.htm | Example of zipping files in APL+Win]])
Line 10: Line 12:
 {{{tn←zip_file_name ⎕NCREATE 0}}}<<BR>>
 {{{(22↑80 75 5 6)⎕NAPPEND tn 83}}}<<BR>>
 {{{⎕NUNTIE tn}}}<<BR>>
{{{
tn←zip_file_name ⎕NCREATE 0
(22↑80 75 5 6)⎕NAPPEND tn 83
⎕NUNTIE tn
}}}
Once the zip file is present, create an instance of the Shell COM...
Line 14: Line 19:
Once the zip file is present, create an instance of the Shell COM...
 
{{{'SHAPP'⎕WC'OLEClient' 'Shell.Application'}}}<<BR>>
{{{
'SHAPP'⎕WC'OLEClient' 'Shell.Application'
}}}
Line 19: Line 24:
 {{{ADD←SHAPP.NameSpace⊂add_folder_name}}}<<BR>>
 {{{FILES←ADD.Items}}}<<BR>>
 {{{ZIP←SHAPP.NameSpace⊂zip_file_name}}}<<BR>>
{{{
ADD←SHAPP.NameSpace⊂add_folder_name
FILES←ADD.Items
ZIP←SHAPP.NameSpace⊂zip_file_name
}}}
Line 25: Line 31:
 {{{ZIP.CopyHere FILES(4+16)}}}<<BR>>
{{{
ZIP.CopyHere FILES(4+16)
}}}
Line 30: Line 37:

Please note also that this stuff works only on versions of Windows that actually have the zipping capability, i.e. it won't zip anything on e.g. Windows 2000 but instead overwrite any existing ZIP file.

KlausKlug 2008

ZIPping with Windows Shell

... here in Dyalog APL syntax.

(Example of zipping files in APL+Win)

Suddenly I came in need of zipping files. And what more obvious solution than to use the zip-facilities already present in Windows? In essence it can be accomplished in a 3 (+1 if you don't already have a zip file) step process as follows.

If need be first create an empty zip file, basically a file with these 22 byte values: 80 75 5 6 0 ... 0:

tn←zip_file_name ⎕NCREATE 0
(22↑80 75 5 6)⎕NAPPEND tn 83
⎕NUNTIE tn

Once the zip file is present, create an instance of the Shell COM...

'SHAPP'⎕WC'OLEClient' 'Shell.Application'

... get a handle to the files, here a folder and the zip archive, calling the NameSpace method...

ADD←SHAPP.NameSpace⊂add_folder_name
FILES←ADD.Items
ZIP←SHAPP.NameSpace⊂zip_file_name

... and finally have all files in that folder copied to the ZIP archive,

ZIP.CopyHere FILES(4+16)

where 4 means "don't display a progress dialog box", and 16 "respond with 'Yes to All' for any dialog box that is displayed".

Note that FILES can be a FolderItems object (as here), a FolderItem object (result from the Item method), or a string that represents a file name.

Please note also that this stuff works only on versions of Windows that actually have the zipping capability, i.e. it won't zip anything on e.g. Windows 2000 but instead overwrite any existing ZIP file.

KlausKlug 2008

ZippingWithWindowsShell (last edited 2017-02-16 19:22:55 by KaiJaeger)