Skip navigation

Help With Finder Scripts / Automator

1748 Views 5 Replies Latest reply: Jan 12, 2013 2:53 PM by Globalksp RSS
Globalksp Calculating status...
Currently Being Moderated
Jan 1, 2013 12:28 PM

Happy New Year all (those of us on the gregorian calendar anyway)!

 

This question revolves around my hope/desire that there are ways for either scripts or automator to perform repetative tasks for me. My knowledge of OS doesn't extend into these two features and while I've been reading up on them, I'm still a bit lost. I have no idea if any of these actions can be automated, I'm merely hoping. 

 

What I'd like to happen:

 

  • Folder Creation and Naming: I routinely need to create multiple, empty, "shot folders" (for photoshoots) that are nested within other folders.
    • Example: /desktop/ShootName/Capture/Shot01, Shot02, Shot03, Shot04, etc... often times into the 10's of folders.
    • I'd be happy with the creation of the folders alone. I can rename with renaming apps (Rename, being my app of choice)
  • Open Three Finder Windows: Three windows open and scale themselves to fit horizontally on the screen (one atop the other atop the other)
    • Screen shot 2013-01-01 at 3.23.00 PM.jpg

 

So far that's all I've found that I could need at the moment. I realize the hangups for each (i.e. how to know how many folders to create on each instance) and I'm sure there are things I haven't foreseen.

 

Any knowledge or resources to other helpful scripts/actions are appreciated!

 

-K

MacBook Pro (15-inch Early 2011), Mac OS X (10.6.8), Mid-2011, 500GB, 2.2GHz i7, 8GB
  • Jacques Rioux Level 4 Level 4 (1,925 points)
    Currently Being Moderated
    Jan 1, 2013 3:33 PM (in response to Globalksp)

    Hi,

     

     

    Here is an AppleScript to start.

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

    set screenBounds to {0, 44, 1920, 1640} -- screen rect, change according to your needs.
    set aName to "Shoot" -- some folder name to rename each created folder
    set targetFolder to choose folder with prompt "Select the directory to create folders"
    display dialog "How many folders you want to create." default answer "10"
    set n to (text returned of the result) as integer
    
    ---** create folder **---
    repeat with i from 1 to n
        if i < 10 then
            set x to aName & "0" & i
        else
            set x to aName & i
        end if
        tell application "Finder" to make new folder at targetFolder with properties {name:x}
    end repeat
    
    set nWind to 3 ---**  create Finder Window **---
    tell screenBounds to set {h, b} to {((item 4) - (item 2) + ((22 * nWind) + 22)) div nWind, it}
    set item 4 of b to h
    repeat with i from 1 to nWind
        tell application "Finder" to tell (make new Finder window)
            set target to targetFolder
            set bounds to b
        end tell
        set h1 to item 4 of b
        tell b to set {item 2, item 4} to {h1 + 22, h1 + h - 22}
    end repeat
    

     

    Since I don't have enough information, the script will not be as you wish, so please don't hesitate to ask the necessary additions or change to this script.

  • Jacques Rioux Level 4 Level 4 (1,925 points)
    Currently Being Moderated
    Jan 2, 2013 6:21 PM (in response to Globalksp)

    Hi,

     

     

    Globalksp wrote:

     

    Just ran the scripts.

     

    The three window script (the 2nd one) did throw back an error

     

    The firsts lines of script are needed, because I thought it was for the same script.

     

     

    Here is a script for Finder windows only:

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

    set r to do shell script "/usr/sbin/system_profiler −detailLevel mini SPDisplaysDataType | awk '/Resolution/{print $2 \" \" $4}'" -- get display's width and height
    set {x, y, w, h} to {0, 22, (word 1 of r) as integer, (word 2 of r) as integer}
    set targetFolder to choose folder with prompt "Select a directory to set the target of each Finder window"
    
    set nWind to 3 ---**  the number of  Finder Window to create **---
    tell (h div nWind) to set {h, a} to {it, it}
    repeat with i from 1 to nWind
        tell application "Finder" to tell (make new Finder window)
            set target to targetFolder
                set bounds to {x, y + 22, w, h}
        end tell
        set {y, h} to {h, h + a}
    end repeat
    

     

     

    If you want the default window's target:

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

    set r to do shell script "/usr/sbin/system_profiler −detailLevel mini SPDisplaysDataType | awk '/Resolution/{print $2 \" \" $4}'" -- get display's width and height
    set {x, y, w, h} to {0, 22, (word 1 of r) as integer, (word 2 of r) as integer}
    set nWind to 3 ---**  the number of  Finder Window to create **---
    tell (h div nWind) to set {h, a} to {it, it}
    repeat with i from 1 to nWind
        tell application "Finder" to tell (make new Finder window)
            set bounds to {x, y + 22, w, h}
        end tell
        set {y, h} to {h, h + a}
    end repeat
    

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.