cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Any way to output to multiple txt files with unique filenames using ACL?

tmanagement
4-Participant

Any way to output to multiple txt files with unique filenames using ACL?

Here's the line of code that creates a txt file on my C: drive. $var1 is just text.

eval $var1 output=C:\reports\report_1.txt;

 

I have multiple documents open and want to create a report of each document, but when I run the script, the output text file gets overwritten for every document I want a report of. I would like it so that each time I run the script on a different document, I get a new text file (i.e., report_1.txt, report_2.txt, report_3.txt).

 

I've tried using a variable in the output filename like below, but unless I source my acl file every time before running my script, it won't create multiple unique files. The eval command doesn't recognize the $n variable and just creates the filename without the variable.

eval $var1 output=C:\reports\report_$n.txt;

 

I've also tried putting the path of the filename into a variable, but that doesn't work either.

$path_var = C:\reports\report_$n.txt;

eval $var1 output=$path_var;

 

Anybody have an idea of how to solve this without hiring someone to manually rename each text file before running the report script?


Thank you in advance.

ACCEPTED SOLUTION

Accepted Solutions

You can use the execute function to get around ACL's habit of preassigning variable values used in command syntax. So, instead of

 

eval $var1 output=C:\reports\report_$n.txt;

 

you can use this

 

local cmd = "eval \"" . $var1 . "\" output=C:\reports\report_" . $n . ".txt;";

execute(cmd);

 

That should make sure the output location doesn't get interpreted until you actually run the execute command. Also, if you want to append output instead of overwriting a file, add a ">" after the equal sign in the output parameter.

 

--Clay

View solution in original post

2 REPLIES 2

You can use the execute function to get around ACL's habit of preassigning variable values used in command syntax. So, instead of

 

eval $var1 output=C:\reports\report_$n.txt;

 

you can use this

 

local cmd = "eval \"" . $var1 . "\" output=C:\reports\report_" . $n . ".txt;";

execute(cmd);

 

That should make sure the output location doesn't get interpreted until you actually run the execute command. Also, if you want to append output instead of overwriting a file, add a ">" after the equal sign in the output parameter.

 

--Clay

Thank you for your input! I had to mind my quotes, but it worked.

Announcements

Top Tags