KMH

Q: applescript: create folders using xcel file

Hello,

I am completely in the dark when it comes to Applescript. Ive been pounding the forums all day, and managed to Frankenstein a few scripts together, but cant quite get this script to work.

Ive attached a screen capture of the script, and the excel file its reading from.

 

Essentially, Im trying to create an Applescript using the excel file i have:

create a heirarchy of folders, using profile (col A) and color names (col C) then copy a couple images (cols F and H) from existing folders (defined in the script), to the newly created color folders (from col C).

 

Heirarchy like this:

GOLDEN EAGLE (profile: top level folder)

     –KINGS CANYON (color: subfolder)

          –1634.jpg (image file copied from other local folder)

          _1634_skin.jpg (image file copied from other local folder)

 

Issues not addressed in current script:

Col A, has tons of duplicates...but I only need 1 folder for each profile. (1 GOLDEN EAGLE folder, 1 BEL AIR folder, etc)

 

Currently when i RUN the script, i get the first folder (GOLDEN EAGLE) but it errors after that.

 

Ive got a script that creates the folder heirarchy flawlessly. But then i was tasked with copying all these images into each folder. So, im trying to combine them into 1 script.

 

Please, I really dont want to do this manually, as there are over 1000 images...any help would be greatly appreciated!

 

Screen Shot 2015-05-21 at 4.22.13 PM.pngScreen Shot 2015-05-21 at 4.23.13 PM.png

MacBook Pro with Retina display, OS X Mavericks (10.9.5)

Posted on May 21, 2015 5:17 PM

Close

Q: applescript: create folders using xcel file

  • All replies
  • Helpful answers

  • by Jacques Rioux,Helpful

    Jacques Rioux Jacques Rioux May 22, 2015 8:09 AM in response to KMH
    Level 4 (3,408 points)
    Mac OS X
    May 22, 2015 8:09 AM in response to KMH

    Hi,

     

     

    Because the profileFolder variable contains a string.

    Use this in the "application Finder" block --> set profileFolder to folder v1 of myFolder ,   now the profileFolder variable contains an object (a Finder item)

     

     

    Try this:

    ----------------------

    set tc to count myData

    repeat with x from 2 to tc

         tell item x of myData to set {v1, v2, v3, v4} to {item 1, item 3, item 6, item 8}

         if v1 = "" or v2 = "" or v3 = "" or v4 = "" then exit repeat

         tell application "Finder"

              if not (exists folder v1 of myFolder) then make new folder at myFolder with properties {name:v1}

              set profileF to folder v1 of myFolder

              if not (exists folder v2 of profileF) then make new folder at profileF with properties {name:v2}

              set colorF to folder v2 of profileF

              try

                   --duplicate file v3 of folder "Volumes:KMH BACKUP:Dropbox:EAGLE:" to colorF

              end try

              try

                   --duplicate file v4 of folder "Volumes:KMH BACKUP:Dropbox:EAGLE:" to colorF

              end try

         end tell

    end repeat

  • by KMH,

    KMH KMH May 22, 2015 11:41 AM in response to Jacques Rioux
    Level 1 (5 points)
    May 22, 2015 11:41 AM in response to Jacques Rioux

    Jacques!

    You are the absolute best! Your script creates the folders flawlessly!

    Yet the TRY (collection of images) produced an error. Im thinking it has to do with the path? Maybe i have to have the absolute path starting from the Startup disk?

    None the less, thank you so much for your expertise!

    Let me know if you can see anything obvious from below.

    Heres the error, starting from the folder creation:

     

    tell application "Finder"

        exists folder "Bel Air" of alias "Macintosh HD:Users:kevinherr:Desktop:EAGLE-Photo Folders-NEW:"

            --> false

        make new folder at alias "Macintosh HD:Users:kevinherr:Desktop:EAGLE-Photo Folders-NEW:" with properties {name:"Bel Air"}

            --> folder "Bel Air" of folder "EAGLE-Photo Folders-NEW" of folder "Desktop" of folder "kevinherr" of folder "Users" of startup disk

        get folder "Bel Air" of alias "Macintosh HD:Users:kevinherr:Desktop:EAGLE-Photo Folders-NEW:"

            --> folder "Bel Air" of folder "EAGLE-Photo Folders-NEW" of folder "Desktop" of folder "kevinherr" of folder "Users" of startup disk

        exists folder "Arcadia" of folder "Bel Air" of folder "EAGLE-Photo Folders-NEW" of folder "Desktop" of folder "kevinherr" of folder "Users" of startup disk

            --> false

        make new folder at folder "Bel Air" of folder "EAGLE-Photo Folders-NEW" of folder "Desktop" of folder "kevinherr" of folder "Users" of startup disk with properties {name:"Arcadia"}

            --> folder "Arcadia" of folder "Bel Air" of folder "EAGLE-Photo Folders-NEW" of folder "Desktop" of folder "kevinherr" of folder "Users" of startup disk

        get folder "Arcadia" of folder "Bel Air" of folder "EAGLE-Photo Folders-NEW" of folder "Desktop" of folder "kevinherr" of folder "Users" of startup disk

            --> folder "Arcadia" of folder "Bel Air" of folder "EAGLE-Photo Folders-NEW" of folder "Desktop" of folder "kevinherr" of folder "Users" of startup disk

        copy file "4502.jpg" of folder "Volumes:KMH BACKUP:Dropbox:EAGLE:EAGLE_www-FW:EAGLE_images:panels:" to folder "Arcadia" of folder "Bel Air" of folder "EAGLE-Photo Folders-NEW" of folder "Desktop" of folder "kevinherr" of folder "Users" of startup disk

           --> error number -1728 from folder "Volumes:KMH BACKUP:Dropbox:EAGLE:EAGLE_www-FW:EAGLE_images:panels:"

        copy file "4502_skin.jpg" of folder "Volumes:KMH BACKUP:Dropbox:EAGLE:EAGLE_www-FW:EAGLE_images:panels:" to folder "Arcadia" of folder "Bel Air" of folder "EAGLE-Photo Folders-NEW" of folder "Desktop" of folder "kevinherr" of folder "Users" of startup disk

           --> error number -1728 from folder "Volumes:KMH BACKUP:Dropbox:EAGLE:EAGLE_www-FW:EAGLE_images:panels:"

        exists folder "Bel Air" of alias "Macintosh HD:Users:kevinherr:Desktop:EAGLE-Photo Folders-NEW:"

            --> true

  • by KMH,

    KMH KMH May 22, 2015 12:04 PM in response to KMH
    Level 1 (5 points)
    May 22, 2015 12:04 PM in response to KMH

    Forgot to mention...the image this script is reading from are on an external drive. However, i could have the script run to the same location...haven't tried that yet...not sure if that is the issue or not.

     

    Thanks again!!

  • by Jacques Rioux,Solvedanswer

    Jacques Rioux Jacques Rioux May 22, 2015 5:16 PM in response to KMH
    Level 4 (3,408 points)
    Mac OS X
    May 22, 2015 5:16 PM in response to KMH

    Hi,

     

    KMH wrote:

     

        copy file "4502.jpg" of folder "Volumes:KMH BACKUP:Dropbox:EAGLE:EAGLE_www-FW:EAGLE_images:panels:" to folder "Arcadia" of folder "Bel Air" of folder "EAGLE-Photo Folders-NEW" of folder "Desktop" of folder "kevinherr" of folder "Users" of startup disk

          --> error number -1728 from folder "Volumes:KMH BACKUP:Dropbox:EAGLE:EAGLE_www-FW:EAGLE_images:panels:"

        copy file "4502_skin.jpg" of folder "Volumes:KMH BACKUP:Dropbox:EAGLE:EAGLE_www-FW:EAGLE_images:panels:" to folder "Arcadia" of folder "Bel Air" of folder "EAGLE-Photo Folders-NEW" of folder "Desktop" of folder "kevinherr" of folder "Users" of startup disk

          --> error number -1728 from folder "Volumes:KMH BACKUP:Dropbox:EAGLE:EAGLE_www-FW:EAGLE_images:panels:"

     

    Yes, the issue is the path of the "panels" folder, remove "Volumes:", because HFS path (path with colon character) doesn't need the "Volumes:"

     

    If this does not work :

    To get the right path : run this script :

    set the clipboard to (choose folder with prompt "Select the 'panels' folder") as string

     

    Now the path is in the clipboard, paste it in your script

  • by KMH,

    KMH KMH May 22, 2015 5:46 PM in response to Jacques Rioux
    Level 1 (5 points)
    May 22, 2015 5:46 PM in response to Jacques Rioux

    Jacques!

    That did the trick! Worked perfectly. Just removed VOLUMES from the path.

    Thank you again for your amazing skills. I see your name all over this forum...for a very good reason...

    Your awesome!

     

    off the record:

    Could you recommend a resource for learning AppleScript, for an idiot like me? I don't think there is an 'AppleScript for Dummies' book.

    Thanks again!

  • by Jacques Rioux,

    Jacques Rioux Jacques Rioux May 25, 2015 8:06 AM in response to KMH
    Level 4 (3,408 points)
    Mac OS X
    May 25, 2015 8:06 AM in response to KMH

    Hi,

     

    KMH wrote:

     

    Could you recommend a resource for learning AppleScript, for an idiot like me? I don't think there is an 'AppleScript for Dummies' book.

    Thanks again!

     

    Starting out with AppleScript