3 Replies Latest reply on Aug 20, 2015 8:11 AM by JonnyDL

    applescript error I don't understand why its occuring

    JonnyDL Level 1

      Im writing a script that will convert photos from color to black and white. I wrote it at home on cs 5.1 and it worked flawlessly, but when I took it to work on a cs6 version it went buggy. again the code below works on 5.1 but when run at work  it gets into the photoshop handler convertpics() errors.

      It errors on change mode line. when run i get the word mode highlighted snd "Expected end of line, etc. but found identifier." it (also) doesn't seem to like the use of Document 1 or current document.in the other lines? Is it how I/m writing it that the dictionary/synatax has changed. ( i couldn't find ant difference). This one is racing my brain because to me it makes no scene. HELP!


      global picfolder

      global origimages


      tell application "Finder"

      set myhome to (path to home folder) as string

      set picfolder to myhome & "Documents:Dark Side:"


      if (exists (folder picfolder)) then

      movePics(picfolder) of me


      make new folder at myhome & "Documents" with properties {name:"Dark Side"}

      end if

      set myPath to (path to home folder) as string


      end tell

      -------------------test to see if files are already there------------------------------------

      -------------------test to make sure original files still are there---------------------------

      on movePics(picfolder)

      tell application "Adobe InDesign CS5.5"

      tell document 1

      set linkList to file path of links

      repeat with linknumber from 1 to count of linkList

      set docimage to item linknumber of linkList

      tell application "Finder"

      copy file docimage to folder picfolder

      end tell

      end repeat

      end tell

      convertpics(picfolder) of me

      end tell

      end movePics


      on convertpics(picfolder)

      tell application "Finder" to set origimages to files of entire contents of folder picfolder

      repeat with i in origimages

      set oneImage to i as string

      tell application "Adobe Photoshop CS5.1"

      open file oneImage

      change mode of document 1 to grayscale

      set fname to name of current document as string

      set myFile to picfolder & fname & "_BW"

      save current document in file myFile as TIFF with options {byte order:Mac OS, embed color profile:false, image compression:LZW, save alpha channels:false, save layers:false} appending lowercase extension

      close current document without saving

      end tell


      end repeat

      end convertpics