Article View: adobe.photoshop.scripting
Article #2086Read text file, open images
From: matthewrubino
Date: Wed, 23 Jun 2004 14:38
Date: Wed, 23 Jun 2004 14:38
21 lines
2584 bytes
2584 bytes
Okay, I'm getting pretty frustrated with this. I'm trying to prompt a user to open a text file, read that comma delimited file which references image files, rotates them, then outputs the rotated image as a TIFF. It seems like every alternative I try leads me to a dead end. I had written a functioning VBScript but could not get the open dialog to pass the file name as a variable (I used the BrowseForFolder method which wouldn't hold a file name but only a folder name--there is no BrowseForFile for some reason). So, I rewrote my script in JavaScript because it simply uses the openDialog method--no problem. I read in the text file as an array(looping through lines) and assigning array elements to variables. A quick test with alert() shows these are being read and passed no problem. However, my first array element is an image file-path reference, yet it will not open the image. Here's a test script to see if I can get Photoshop to open the referenced image:
// Set input file path as variable
var inPath = "S:/tmpPhotoRotate/tif/";
// Open a dialog to prompt user to select a text file
var openFile = File.openDialog ("Select a text file", "Text Files:*.txt");
if(openFile.open('r'))
{
var aLine
// While Loop
while(aLine = openFile.readln())
{
// Create array
var elements = aLine.split(",");
var eleInFileName = (inPath + elements[0]).toString();
app.open(eleInFileName);//<---error occurs here //some additional element variables here } openFile.close() }
What is it about open that gives me an error? The only thing I could think of was that it's not reading that text as a string (I figured the toString() would help) and just can't get past. Is it syntax? Am I trying to do something impossible? Anyone tried this before?
Technical Details
Message-ID:
<3bb4bc89.-1@webx.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!transit.news.xs4all.nl!newsgate.cistron.nl!news2.euro.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!news-out.ntli.net!newsrout1.ntli.net!news-in.ntli.net!ntli.net!newsfeed01.sul.t-online.de!t-online.de!webxShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f5839,3e19365c4290ecca,start X-Google-Attributes: gidf5839,public From: matthewrubino@adobeforums.com Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!transit.news.xs4all.nl!newsgate.cistron.nl!news2.euro.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!news-out.ntli.net!newsrout1.ntli.net!news-in.ntli.net!ntli.net!newsfeed01.sul.t-online.de!t-online.de!webx Newsgroups: adobe.photoshop.scripting Subject: Read text file, open images Message-ID: <3bb4bc89.-1@webx.la2eafNXanI> Date: Wed, 23 Jun 2004 07:38:05 -0700 Lines: 42 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit