Note that there are some explanatory texts on larger screens.

plurals
  1. POHow does one feed a list of files into an app with appscript and Python?
    text
    copied!<p>Get your newb-shields up, I'm about to sprinkle you with some.<br> I'm trying to get Photoshop CS4 to open a folderful of JPEG images with AppScript+Python, which could be described like so in BASH: </p> <pre><code>#!/bin/bash for F in `ls ~/Desktop/test`; do open -a "Adobe Photoshop CS4" $F # proceed to mutilate the image appearance done </code></pre> <p>I'm failing at the <code>ls ~/Desktop/test</code> stage. I'd really like to ask Finder to list a folder for me, and feed the result into Photoshop one at a time to process them.<br> A JavaScript equivalent with Adobe's ExtendScript bridge would be: </p> <pre><code>#target photoshop var folder = Folder("~/Desktop/test"); var images = folder.getFiles(); for (var i=0; i &lt; images.length; i++) { if (images[i] instanceof File &amp;&amp; images[i].hidden == false) { var doc = app.open(images[i]); // do something to the image here doc.close(SaveOptions.DONOTSAVECHANGES); } } </code></pre> <p>I can get me a <code>document_file</code> object with a horribly silly contraption like <code>x = app('Finder').home.folders['Desktop']().folders['test']().items()[0]</code>, but that turns out to be a really silly object. Trying to <code>app('Adobe Photoshop CS4').open(x)</code> this object will throw an <code>OSERROR: 1230</code>, with a <code>MESSAGE: File/Folder expected</code>. </p> <p><em>(Uh-oh, this <code>document_file</code> actually responds to <code>URL()</code>, so <code>File.makewithurl(x.URL())</code> can be fed into <code>open()</code>)</em></p> <p>Ehm, having solved that, is there a way to actually do this by asking Finder for the list of files in a given folder, specified by a <em>UNIX path</em>? </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload