Applescript Guru to write simple, seemingly easy short script
May 17, 2010 12:07 PM   Subscribe

I have two mirrored hard drives, B and backup_B. I'm looking for an applescript that will identify the location of an open window on the B directory and will then open the same mirrored directory on the backup_B. All I can offer you is to become the successor of my vast empire. Thanks a million.
posted by captainscared to Computers & Internet (4 answers total)
 
Best answer: To clarify: You have a Finder window open displaying some folder on B and you want a script that, when run, will open the corresponding folder on backup_B?

My AppleScript is a little rusty, but I'm pretty sure this will do it, though it's a little hard for me to test completely because I don't have a mirrored drive setup. You will, of course, have to replace "backup_B" with the actual name of your drive.

on run
tell application "Finder"
activate

set curFolder to (folder of the front window as string)

set AppleScript's text item delimiters to ":"

set pathItems to every text item of curFolder

set item 1 of pathItems to "backup_B"

set newFolder to pathItems as string

make new Finder window to newFolder

set AppleScript's text item delimiters to {""}

end tell
end run

posted by jedicus at 1:02 PM on May 17, 2010 [1 favorite]


on run
tell application "Finder"
activate
set this_folder to (the target of the front window) as alias as string

repeat until this_folder ends with ":"
set this_folder to text 1 through -2 of this_folder
end repeat

repeat until this_folder begins with ":"
set this_folder to text 2 through -1 of this_folder
end repeat

set that_folder to "backup_B" & this_folder

open that_folder
end tell
end run
posted by ook at 1:03 PM on May 17, 2010


(Ha, missed it by that much. Jedicus's method looks much cleaner than mine; use his.)
posted by ook at 1:06 PM on May 17, 2010


Response by poster: Thanks so much. Works like a charm. Thanks for trying ook.
posted by captainscared at 2:08 PM on May 17, 2010


« Older What to do about a frog?   |   Does tiling cost more based on tile size? Newer »
This thread is closed to new comments.