Don't understand @perfile basic usage

Continuing the discussion from Script/Button to clean subdirectories in a compressed file (.cbz):

I have been using previous script one file by one file without problem, but when I want to configure it for selecting multi-files and excecute recursively for each one I am stuck.

I have made a basic script for trying to understand what happen

@nofilenamequoting
@nodeselect
@runmode hide
//
@output ---SCRIPT INIT---
@set file_init={file$}
@output: {$file_init}
@Output ---FIN SCRIPT---


in this case I have this output if I select 3 files

---SCRIPT INIT---
---SCRIPT INIT---
---SCRIPT INIT---
Python's Bromas Saladas 09.cbr
Python's Bromas Saladas 09.cbr
Python's Bromas Saladas 09.cbr
---FIN SCRIPT---
---FIN SCRIPT---
---FIN SCRIPT---

That means, each command is executed 3 times. I also don't understand why the file name for the first file is maintaned. I understand I should have the three file names.

Then I try to configure it adding @perfile command as you explain before.

@nofilenamequoting
@nodeselect
@runmode hide
//
@perfile:begin
@output ---SCRIPT INIT---
@set file_init={file$}
@output: {$file_init}
@Output ---FIN SCRIPT---
@perfile:end

Then when I try to run the script.... nothing happen. No output at all.
I don't understand why I am stuck in something should be so basic... I may be missing a real basic point somewhere.
Thanks for any help.

May I confuse you a bit more? Run this, with and without perfile:

@nofilenamequoting
@nodeselect

@perfile:begin
@output ---SCRIPT INIT---
@set file_init={file$}
@output:Hola {$file_init}
@output:Hi {=file=}
=Output("Hello " + file)
@Output ---FIN SCRIPT---
@perfile:end

Not dizzy enough yet? There is more!

Import this user command

@output:&string&

OutputUC.ouc

and run:

@nofilenamequoting
@nodeselect

@perfile:begin
@output ---SCRIPT INIT---
@set file_init={file$}
@output:Hola {$file_init}
@output:Hi {=file=}
=Output("Hello " + file)
OutputUC STRING="Salut {file$}"
@Output ---FIN SCRIPT---
@perfile:end

I select TWO Files (09 and 10)

Running Script 1

1- Just copied with @perfile as you indicate : No output at all
2- Comenting @perfile: output

---SCRIPT INIT---
---SCRIPT INIT---
Hola Python's Bromas Saladas 09.cbr
Hola Python's Bromas Saladas 09.cbr
Hi Python's Bromas Saladas 09.cbr
Hi Python's Bromas Saladas 10.cbr
---FIN SCRIPT---
---FIN SCRIPT---

Now file OutputUC.ouc imported and run the second script

Running Script 2

1- Just copied with @perfile as you indicate: there is output

> OutputUC STRING="Salut Python's Bromas Saladas 09.cbr"
> OutputUC STRING="Salut Python's Bromas Saladas 10.cbr"

2- Comenting @perfile: output

---SCRIPT INIT---
---SCRIPT INIT---
Hola Python's Bromas Saladas 09.cbr
Hola Python's Bromas Saladas 09.cbr
Hi Python's Bromas Saladas 09.cbr
Hi Python's Bromas Saladas 10 - Especial Matrimonios!.cbr
> OutputUC STRING="Salut Python's Bromas Saladas 09.cbr"
> OutputUC STRING="Salut Python's Bromas Saladas 10 - Especial Matrimonios!.cbr"
---FIN SCRIPT---
---FIN SCRIPT---

Running Script 3

After viewing previous results I decided to test a thirs script using changing @output to OutputUC

@nofilenamequoting
@nodeselect

@perfile:begin
OutputUC ---SCRIPT INIT---
@set file_init={file$}
OutputUC Hola {$file_init}
OutputUC Hi {=file=}
=Output("Hello " + file)
OutputUC STRING="Salut {file$}"
OutputUC ---FIN SCRIPT---
@perfile:end

With @perfile : output is

> OutputUC ---SCRIPT INIT---
> OutputUC Hola 
> OutputUC Hi Python's Bromas Saladas 09.cbr
> OutputUC STRING="Salut Python's Bromas Saladas 09.cbr"
> OutputUC ---FIN SCRIPT---
> OutputUC ---SCRIPT INIT---
> OutputUC Hola 
> OutputUC Hi Python's Bromas Saladas 10.cbr
> OutputUC STRING="Salut Python's Bromas Saladas 10.cbr"
> OutputUC ---FIN SCRIPT---

With //@perfile: output is

> OutputUC ---SCRIPT INIT---
> OutputUC ---SCRIPT INIT---
> OutputUC Hola Python's Bromas Saladas 09.cbr
> OutputUC Hola Python's Bromas Saladas 09.cbr
> OutputUC Hi Python's Bromas Saladas 09.cbr
> OutputUC Hi Python's Bromas Saladas 10.cbr
> OutputUC STRING="Salut Python's Bromas Saladas 09.cbr"
> OutputUC STRING="Salut Python's Bromas Saladas 10.cbr"
> OutputUC ---FIN SCRIPT---
> OutputUC ---FIN SCRIPT---

OK. I understand now that

  • before it wasnt the script with @perfile wan't running. Really it wasn't showing any output.
  • you have found a way to substitute the @output command

Then I am going to include in the script some commands to see how it behave.

@nofilenamequoting
@nodeselect

@perfile:begin
OutputUC ---SCRIPT INIT---
@set file_init={file$}
@set extract_dir={sourcepath$}{file$|noext}
OutputUC Fichero {=file=} 
OutputUC Directorio {=sourcepath=}{=file=}
//OutputUC Extract Dir {=extract_dir=}
//C:\USBTools\Utilities\7z.exe e -o"{extract_dir$}" "{file$}" -aou
C:\USBTools\Utilities\7z.exe e -o"n:\test\Extract" "{sourcepath$}{file$}" -aou
Delete "n:\test\Extract" RECURSE QUIET
OutputUC ---FIN SCRIPT---
@perfile:end

As you see I am not able tu use extract_dir variable it doesn't work.
If I uncomment
"//OutputUC Extract Dir {=extract_dir=}"
it stop working (no output, no effect on the diretories)

Then I fix some variable in order to see how it work
Running the script, senerate this output:

> OutputUC ---SCRIPT INIT---
> OutputUC Fichero TEST 09.cbr 
> OutputUC Directorio N:\TEST\TEST 09.cbr
> C:\USBTools\Utilities\7z.exe e -o"n:\test\Extract" "N:\TEST\TEST 09.cbr" -aou
> Delete "n:\test\Extract" RECURSE QUIET
> OutputUC ---FIN SCRIPT---
> OutputUC ---SCRIPT INIT---
> OutputUC Fichero TEST 10.cbr 
> OutputUC Directorio N:\TEST\TEST 10.cbr
> C:\USBTools\Utilities\7z.exe e -o"n:\test\Extract" "N:\TEST\TEST 10.cbr" -aou
> OutputUC ---FIN SCRIPT---

Then I see the function of @perfile is ok (which was the objevtive of this post)
Something I dont understand is why Delete command is not working (the directory remain between both files and later)
And I don't see Delete output for the second file.
Hope you can help me to solve all this "strange behaviour".
But thank you a lot for your suggestions which allow to progress on this issue.

You’ll be my hero if you pull off this archive juggling successfully with a command button. But don’t blame me if you go insane in the process! :wink:

Trust me - been there, done that. Switch to scripting instead :slight_smile:

I have made more tests and as soon as I include a variable extract_dir$ in a @perfile loop I have problems.
Don't understand what is happening.