Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Need help w/program or applescript

Need help w/program or applescript
Thread Tools
Ehellgo
Guest
Status:
Reply With Quote
Nov 1, 2000, 02:02 PM
 
Hi,
I am not much of a programmer, took a class in c in college and taught nyself some VB for Applications. I need to automate something and am not really sure how to do it. Here is what I need done. I am printing out a bunch of pictures at a time through photoshop. Currently I put all of the pictures that I am printing into a folder, run a batch, and they print out.
I would like to stream line this process by creating an applescript, or some other program that would take a list from a text document, find all of the files in that list and put them in my photoshop printing folder. I would appreciate any help on this. I am open to any suggestions that you might have.

Thanks....
     
Dedicated MacNNer
Join Date: Nov 1999
Location: Georgetown, Demerara, Guyana
Status: Offline
Reply With Quote
Nov 6, 2000, 03:33 AM
 
Hi Ehellgo,

If you haven't already written your script/program or found an alternative solution, I believe that the task can be more easily accomplished in AppleScript than in a "traditional" programming language. For instance, reading a file (and file I/O in general) is readily done via the "File Read/Write" commands of the 'Standard Additions' OSAX (in the 'Scripting Additions' subfolder of the System Folder), and relocating a file is tailor-made for the 'move' command of the scriptable Finder, all without having to make any potentially cumbersome File System API calls.

As usual, all available commands ("dictionaries") of the 'Standard Additions' OSAX and the Finder can be viewed by opening each of them via the Script Editor's 'File|Open Dictionary...' menu item, or by just dragging-&-dropping each of them onto the Script Editor.

I'll assume that the image files all reside in the same source folder, that they are all destined for a single target folder, that the list-file (of image filenames) is sufficiently small to be easily manipulated in memory, and that the list-file has the following format:-
  • ImageFilename1
    ImageFilename2
    [...]
    ImageFilenameN

Given the above assumptions, here's a sample script that attempts to read each image filename from the list-file, and to move it from its source folder into the target folder:-
Code:
on run try (* NOTE:- Instead of manually setting the three pathnames below, one could instead use the 'choose folder' command of the 'Standard Additions' OSAX to select each folder via a standard dialog, and similarly the 'choose file' command of the 'Standard Additions' OSAX to select the list-file via a standard dialog. *) -- Set the pathname of the source folder set theSourceFolder to "<full pathname of source folder>" -- e.g., "Hard Disk:Image Folder:" -- Set the pathname of the target folder set theTargetFolder to "<full pathname of target folder>" -- e.g., "Hard Disk:PhotoShop Printing Folder:" -- Set the pathname of the list-file set theListFile to "<full pathname of list file>" -- e.g., "Hard Disk:Work Folder:Image List" -- Ensure that the source folder's pathname ends in a colon set theSourceFolderPathname to (theSourceFolder as string) if ((last character of theSourceFolderPathname) is not ":") then set theSourceFolderPathname to (theSourceFolderPathname & ":") end if -- Verify that the list-file exists (will trigger an error if it doesn't) get info for theListFile -- Open the list-file for read-only access set theListFileFRefNum to (open for access theListFile without write permission) -- Read the entire contents of the list-file into memory set theListFileContents to (read theListFileFRefNum) -- Close the list-file close access theListFileFRefNum -- Get the total number of filenames (lines) set theFilenameCount to (number of paragraphs of theListFileContents) -- Loop through each filename (line) repeat with i from 1 to theFilenameCount -- Get the next filename set thisFilename to (paragraph i of theListFileContents) if ((length of thisFilename) > 0) then -- Ignore empty lines -- Build the full pathname set theFullFilename to (theSourceFolderPathname & thisFilename) -- Ask the Finder to move the file to the target folder tell application "Finder" move (item theFullFilename) to (folder theTargetFolder) without replacing end tell end if end repeat --Handle errors on error errMsg number errNum try close access theListFile on error errMsg2 number errNum2 -- Ignore any file I/O cleanup errors end try display dialog ("Sorry, an error occurred!" & return & return & "(" & errNum & ") " & errMsg) ¬ buttons {"Stop"} default button 1 with icon stop end try return end run
In any event, let us know how things worked out.

Regards,

--Paul
     
Ehellgo
Guest
Status:
Reply With Quote
Nov 6, 2000, 07:59 AM
 
Thanks so much for the help. I haven't tried the script yet, but I will as soon as I start working. I will let you know how it goes.

Eric
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 11:02 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2