Hi
I'm not sure if anyone has ever worked with this or if this is the right place to ask this question since it is not really a SAS topic.. but i'll give it a try anyway.
I'm running this :
filename zip pipe "zip -r c:\temp\accept\test.zip c:\temp\accept/*" ;
data _null_;
infile zip;
input;
put _infile_;
run;
And this is working.........
But when I doubleclick on test.zip it appears that the contents of the zip files is in this path :
c:\temp\accept\test.zip\temp\accept
This is not what I want.
It needs to go in :
c:\temp\accept\test.zip
How do I change this 'Windows command' to make sure this will happen ?
I've checked the Info-Zip FAQ but cannot find out what to do.
Thanks
B
Hi,
Just managed to find solution below. The -p parameter did work though, Dave 😉
Thanks everybody
x "cd c:\temp\test";
filename zip pipe "zip -r -p split.zip * " ;
data _null_;
infile zip;
input;
put _infile_;
run;
Regards
B
Yes, thats more of a question for the zip command line people. A check on the documents reveals this:
-p |
--paths |
Include relative file paths as part of the names of files stored in the archive. This is the default. The -j option junks the paths and just stores the names of the files. |
From:
Hi,
Thanks. -j works, however this only compresses root folder contents. I need to compress the whole directory structure including files within folders, hence the use of -r in my script. I tried to use both , but this does not work unfortunately.
Is this structure possible at all ?
zip -j -r foo foo/*
in which foo is the directory path
Thanks
Regards,
B
If you don't want the high level folders in the paths that are included in the ZIP file then don't use them in the command.
So instead of
filename zip pipe "zip -r c:\temp\accept\test.zip c:\temp\accept/*" ;
You want something more like
filename zip pipe "cd c:\temp\accept; zip -r test.zip *" ;
But you might want to write the ZIP file itself to another folder to prevent it from trying to store a copy of the zip file inside itself.
filename zip pipe "cd c:\temp\accept; zip -r ..\test.zip *" ;
Hi Tom,
Thanks for your suggestion. This sounds very logical, except it doesn't do anything, no zipfiles unfortunately.
Something still is wrong in the syntax.. I tried them with a forward slash right before the *, but no success either..
Regards
B
filename zip pipe "cd c:\temp\accept; zip -r test.zip *" ;
filename zip pipe "cd c:\temp\accept; zip -r c:\temp\accept\test.zip *" ;
@Billybob73 wrote:
Hi Tom,
Thanks for your suggestion. This sounds very logical, except it doesn't do anything, no zipfiles unfortunately.
Something still is wrong in the syntax.. I tried them with a forward slash right before the *, but no success either..
Regards
B
filename zip pipe "cd c:\temp\accept; zip -r test.zip *" ;
filename zip pipe "cd c:\temp\accept; zip -r c:\temp\accept\test.zip *" ;
Get the commands to work from command window then use them.
You might need to use an X command to run the CD command separately.
Also I find it useful to use a data _null_ step with piped command do see what messages the command is generating.
data _null_;
infile 'some command' pipe ;
input;
put _infile_;
run;
There might be more advanced ZIP options that allow for you to specify what part of path to include in zip file.
Hi,
I'm sorry but I just do not know how to do this . Also this failed...........
Anyone happens to have this code ?
x "c:\temp\accept";
filename zip pipe "zip -r test.zip" ;
data _null_;
infile zip;
input;
put _infile_;
run;
Regards,
B
You may need to add the -p (or -P) command line option to store the folder names. From the doc:
WZZIP reference
Hi,
Thanks Dave.
I tried to add the -p but nothing happens unfortunately.
x "c:\temp\test";
filename zip pipe "zip -p -r test.zip" ;
data _null_;
infile zip;
input;
put _infile_;
run;
What is wzzip ? I'm using the zip and unzip commands from Info-Zip.
Regards,
B
@Billybob73 sorry about that, I was thinking WinZip, which has separate CLI tools, and I see now you are using Info-Zip.
Hi,
Just managed to find solution below. The -p parameter did work though, Dave 😉
Thanks everybody
x "cd c:\temp\test";
filename zip pipe "zip -r -p split.zip * " ;
data _null_;
infile zip;
input;
put _infile_;
run;
Regards
B
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.