Command line options | How to add them?

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

skrippy
Posts: 14
Joined: Sun Nov 27, 2016 5:34 am
Location: EU

Command line options | How to add them?

Post by skrippy »

Hi again, all :) It's been a while and seems my account even disappeared? Anyway...

I'd like to have an image conversion start from a small script (for PS CC2017), but I can't find the "magic quotes" to also have it start up with command line options...

Something like this is working fine inside a Windows shortcut target field:

Code: Select all

"C:\program.exe" -options "c:\input.tiff" -o "c:\output.tiff"
I'm trying to get the same success from within ExtendScript Toolkit 3.8.0.12

This starts the program fine:

Code: Select all


var convert_it = new File("/c/program.exe");
convert_it.execute();
Adding the command line options, some variations I've probably tried among many...

Code: Select all


var convert_it = new File("/c/program.exe" -options "c:\input.tiff" -o "c:\output.tiff");

var convert_it = new File("'/c/program.exe' -options 'c:\input.tiff' -o 'c:\output.tiff'");

var convert_it = new File("/c/program.exe" -options "/c/input.tiff" -o "/c/output.tiff");

var convert_it = new File("'/c/program.exe' -options '/c/input.tiff' -o '/c/output.tiff'");
Does anyone have a better clue, please...?

Thanks! :)

P.S. RIP and Thank You for Everything, Mike Hale...! :(
xbytor
Posts: 22
Joined: Thu Jan 01, 1970 12:00 am

Re: Command line options | How to add them?

Post by xbytor »

Create a .bat file and write your command line to it the file.execute() the file. Should work.
If not pass your command as a single string and call app.system(). That will execute the command line. It runs async which may or may not be a problem for.
app.system('"C:\program.exe" -options "c:\input.tiff" -o "c:\output.tiff"');
Note the addition of ' to wrap everything into a single string.
skrippy
Posts: 14
Joined: Sun Nov 27, 2016 5:34 am
Location: EU

Re: Command line options | How to add them?

Post by skrippy »

The app.system way is hanging ExtendScript here (meaning, a wheel is turning down below and I have to Debug > Stop it).
The line also highlights red.
(I'm using just that line though, no idea if it needs other code)

With the .bat file it's working perfectly!

Thanks so much! :)