I have a folder with 150 zipped folders in it. Each folder has a device name, followed by an order score, then the date (ie. Device X_2016_07_20.zip). I want to create a new folder with the device name (which I can get working). I can get open a zip folder and see all the different files within, but I can not figure out how to unzip (or even copy) to the new folder. Can someone please give me a hand?

Re: How to unzip using JMP Zip Archive Commands

the next line uses the zip archive object, za, to read a member from the archive. something like this:

za = Open( "$desktop\test.zip", zip );

dirlist = za << dir;

Show( dirlist ); // see all contents of zipped folder

// dirlist = {"fft.jmp", "fft2.jsl"};

For( i = 1, i <= N Items( dirlist ), i++,

If( Right( dirlist, 4 ) == ".jmp" /*binary data*/,

blob = za << read( dirlist, Format( blob ) );

Save Text File( "$desktop\deleteme_" || dirlist, blob );

);

If( Right( dirlist, 4 ) == ".jsl" /*text data*/,

text = za << read( dirlist );

Save Text File( "$desktop\deleteme_" || dirlist, text );

);

);

there are two examples, in bold, because a zip file might contain binary data (a JMP data table in this case) or plain text (a JMP script). The binary data can't be stored in a JSL string, but a BLOB will work. The next line, saveTextFile, understands both strings and BLOBs (and will save a binary file for a BLOB, in spite if its name). You should not depend on the order of the members in the zip file, especially if someone might have edited/added/deleted members from them.

(I'm assuming you want to extract the members, not copy the .zip file to another .zip file. You could do that without opening the zip file at all.)

edit: you can use BLOB for text files too, if you are just copying them. If you want to process the text in JSL, BLOB will make it harder.

Re: How to unzip using JMP Zip Archive Commands

the next line uses the zip archive object, za, to read a member from the archive. something like this:

za = Open( "$desktop\test.zip", zip );

dirlist = za << dir;

Show( dirlist ); // see all contents of zipped folder

// dirlist = {"fft.jmp", "fft2.jsl"};

For( i = 1, i <= N Items( dirlist ), i++,

If( Right( dirlist, 4 ) == ".jmp" /*binary data*/,

blob = za << read( dirlist, Format( blob ) );

Save Text File( "$desktop\deleteme_" || dirlist, blob );

);

If( Right( dirlist, 4 ) == ".jsl" /*text data*/,

text = za << read( dirlist );

Save Text File( "$desktop\deleteme_" || dirlist, text );

);

);

there are two examples, in bold, because a zip file might contain binary data (a JMP data table in this case) or plain text (a JMP script). The binary data can't be stored in a JSL string, but a BLOB will work. The next line, saveTextFile, understands both strings and BLOBs (and will save a binary file for a BLOB, in spite if its name). You should not depend on the order of the members in the zip file, especially if someone might have edited/added/deleted members from them.

(I'm assuming you want to extract the members, not copy the .zip file to another .zip file. You could do that without opening the zip file at all.)

edit: you can use BLOB for text files too, if you are just copying them. If you want to process the text in JSL, BLOB will make it harder.