Skip to main content
Shine BR
Known Participant
November 11, 2017
Answered

Unzip a file

  • November 11, 2017
  • 1 reply
  • 7529 views

Hi Team,

Is there any possibility of unzipping a file from desktop and execute an action through PS.

Correct answer Davide_Barranca12040269

If you're familiar with command-line zip (see Unzipping Files Using Terminal | Mac Tricks And Tips for info), you can write the needed lines into a string and then pass it to the app.system() function, for instance:

var cmd = "cd ~/Desktop/srcFolder\n" +

          "unzip -o test.zip -d ~/Desktop/destFolder";

app.system(cmd);

Hope this helps,

Davide

1 reply

Davide_Barranca12040269
Legend
November 12, 2017

If you're familiar with command-line zip (see Unzipping Files Using Terminal | Mac Tricks And Tips for info), you can write the needed lines into a string and then pass it to the app.system() function, for instance:

var cmd = "cd ~/Desktop/srcFolder\n" +

          "unzip -o test.zip -d ~/Desktop/destFolder";

app.system(cmd);

Hope this helps,

Davide

Davide Barranca - PS developer and authorwww.ps-scripting.com
natrev
Legend
November 13, 2017

Hi Davide,

Is this possible to unzip file from sever..? since I used that code and getting error..

var cmd = "cd //NEWSERVER/Source files\n" + "unzip -o test.zip -d ~/Desktop/dest Folder"; 

app.system(cmd); 

yajiv

Legend
March 19, 2018

To be very honest before you posted your solution my last try had to be with additional quotes (so like in your example), as I tried something like it in deep past and it worked, but then looked once again at code and found, no way, that has no sense - it all looks like that should work. So I didn't eventually try that trick. Even if I did I still had problem. Because your first code does not work. It works only when like in second code you posted the destination folder for unrared content is specified so:

system('""C:\\Program Files (x86)\\WinRAR\\unrar.exe" x "%USERPROFILE%\\Desktop\\test.rar" "%USERPROFILE%\\Desktop""')

That specified destination that should be added at end of code I saw in some exampes I googled, but I did not use that as trying it without it directly from Command Prompt showed it is not needed. Well I thought if in Command Line that is no needed then why that should be used in ESTK. That's not logical for me. THX again that I had no to loose much time on it.


At me all works fine and files are extracted in a folder
C: \ Program Files \ Adobe \ Adobe Photoshop CS6.
I knowingly said about access rights. Or run photoshop with administrator rights