Jump to content











Photo
- - - - -

[Win7PE_SE] Help with unpack command inside script

unpack command script

  • Please log in to reply
6 replies to this topic

#1 Aeolis

Aeolis

    Frequent Member

  • .script developer
  • 145 posts
  • Location:Rio de Janeiro
  • Interests:I am just trying to learn and help.
  •  
    Brazil

Posted 20 November 2011 - 02:06 PM

Hello folks,

I am building my first script to myself and the Reboot.pro community. So, I faced a problem. Here is what I want to do:

I want to extract the contents of File.7z inside the folder Files attached to my script into a folder directly without creating a MyProgram (%ProgramFolder%) inside the destination folder. For this I have used the following line:

Unpack,Files,File.7z,,%pFileBox1%,,,

Where %pFileBox1% is the destination folder chosen by user in the appropriate file box. The problem is that this line always create a folder named MyProgram inside the destination folder.

I just need the files inside the File.7z inside the destination folder not another folder with the Files.7z contents. I hope you can help me here.

Best regards,

Aeolis

Edited by Aeolis, 20 November 2011 - 02:09 PM.


#2 patsch

patsch

    Silver Member

  • Advanced user
  • 785 posts
  •  
    Germany

Posted 20 November 2011 - 03:20 PM

I would use a temporary folder like %TempFolder%/name , extract the content of files.7z into that dir. Then perform a filecopy to the directory you want. After that you can delete this temporary folder.
Afair some scripts that have an option to update the program use that method

#3 Aeolis

Aeolis

    Frequent Member

  • .script developer
  • 145 posts
  • Location:Rio de Janeiro
  • Interests:I am just trying to learn and help.
  •  
    Brazil

Posted 20 November 2011 - 03:33 PM

Hello folks,

Dear patsch, thank you for your help. Could give a commands example? I mean, could you right in commands what you suggest me?

It looks like that:

Unpack,Files,File.7z,,%pFileBox1%,Temp_Extract,,
FileCopy,%pFileBox1%Temp_Extract*.*,%pFileBox1%
DirDelete,%pFileBox1%Temp_Extract


Is it right? Is it impossible to be done with the unpack command?

Best regards,

Aeolis

Edited by Aeolis, 20 November 2011 - 03:50 PM.


#4 patsch

patsch

    Silver Member

  • Advanced user
  • 785 posts
  •  
    Germany

Posted 20 November 2011 - 08:15 PM

sorry, I wrote some scripts but none of them had to use what you exactly need.
I would do it in this way, but some of the script writers around here should have a look at this if it's correct

1.) I would define some variables

[Variables]

%ProgramFolder%=%pFileBox1%

%TmpFolder%=%GlobalTemp%%ProgramFolder%

2.) then the extract/copy-Part (in case your.7z is attached in the script)

[Process]

If,EXISTDIR,"%TmpFolder%",DirDelete,"%TmpFolder%"

DirMake,"%TmpFolder%"

ExtractFile,%ScriptFile%,Folder,your.7z,%TmpFolder%

ShellExecute,Hide,"%Tools%7z.exe","x -y #$q%TmpFolder%your.7z#$q -o#$q%TmpFolder%extract#$q"



[EncodedFolders]

Folder



[Folder]

your.7z, ...


3.) after that you can either make a DirMove or you just do a FileCopy

#5 sbaeder

sbaeder

    Gold Member

  • .script developer
  • 1333 posts
  • Location:usa - massachusettes
  •  
    United States

Posted 20 November 2011 - 08:24 PM

did you try looking at the docs - especially for syntax2? http://code.google.c...der/wiki/unpack

from that, I would "guess" (I did not try this) it might be
Unpack,%SrciptFile%,Archive,Files,File.7z,%pFileBox1%

So, try that and see what happens...AND a log file would help, since there are times when having a trailing "" on a directory name makes a difference,
so you might have to either add (or maybe even remove) a "" from the end of the folder you want to
copy the contents to...also, make sure that the folder exists, etc.

#6 Aeolis

Aeolis

    Frequent Member

  • .script developer
  • 145 posts
  • Location:Rio de Janeiro
  • Interests:I am just trying to learn and help.
  •  
    Brazil

Posted 20 November 2011 - 10:18 PM

Hello folks,

Well, thank you all! Yes, sbaeder I had gone through the help files and I saw that syntax 1 and syntax 2 for unpack command, but without success. I have used your suggestion and it worked. Maybe I was a little sleepy and missed something when reading the help files (thank you again sbaeder). Well, for future reference here are the two commands that worked:

1) This one has more lines, but works.

Unpack,Files,File.7z,,%pFileBox1%,Temp_Extract,,
FileCopy,%pFileBox1%\Temp_Extract\*.*,%pFileBox1%
DirDelete,%pFileBox1%\Temp_Extract


2) This one is much cleaner and do the job too.

Unpack,%ScriptFile%,Archive,Files,File.7z,%pFileBox1%

For now I will keep the version 2 command which is much cleaner. Thank you all.

Best regards,

Aeolis

#7 delta925

delta925

    Newbie

  • Advanced user
  • 10 posts
  •  
    United Kingdom

Posted 03 November 2015 - 01:59 PM

All,

 

I have been struggling to create a script for a similar requirement.

 

A search brought up this thread.

 

By following

 

Unpack,%ScriptFile%,Archive,Files,File.7z,%pFileBox1%

 

together with the explanation of Syntax 2 here

 

https://code.google....der/wiki/unpack

 

I have adapted it and finally have a working script.

 

Thank you.







Also tagged with one or more of these keywords: unpack, command, script

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users