Skip to main content
Participant
February 2, 2012
Answered

Can I export a command (text) file with photoshop and javascript?

  • February 2, 2012
  • 1 reply
  • 602 views

I'm trying to write a script to export images to a "hot folder" that is scanned by our printing software and printed automatically. The software needs to read a command file which is a basic text file giving image dimensions and paper type. Is it possible to create such a file with any of the extenscript tools or does javascript's security features prevent this? Would it work if I converted to VB script? The most progress I've made so far is:

var commandFile = new File();

commandFile.saveDlg("Save the file as command.nhf", "*.nhf");

commandFile.writeln("Test Line");

this brings up a save dialog to save the file but as far as I can tell it is just a temporary file which is deleted as soon as the script is finished. I'm hoping I dont have to learn VB or C# to get this working.

Thanks.

This topic has been closed for replies.
Correct answer Muppet Mark

You are almost there…

var f = File( '~/Desktop/Printer_Info.txt' );

f.open( 'w' );

f.write( 'Hello printer A4 please…' );

f.close();

1 reply

Muppet MarkCorrect answer
Inspiring
February 2, 2012

You are almost there…

var f = File( '~/Desktop/Printer_Info.txt' );

f.open( 'w' );

f.write( 'Hello printer A4 please…' );

f.close();

Participant
February 2, 2012

Thanks, I knew it was something simple but I was so convinced that javascript couldn't do it I didn't realize f.open could create non-existant files and was looking for a workaround when it should have been obvious