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 > macOS > Download File, Open Window?

Download File, Open Window?
Thread Tools
immsav
Fresh-Faced Recruit
Join Date: Dec 2002
Location: Oxford
Status: Offline
Reply With Quote
Apr 26, 2003, 05:43 PM
 
I've got to learn more Applescript!

Specifically, I'm trying to set up a "folder action" so that when I download a file from within Safari, my "downloads" folder automatically opens and comes to the front.

I don't want to automatically run/open files and programs (Safari gives you that option), but I'd like to save myself a click.

Does anyone have any ideas about solutions to this problem, or maybe some good websites with Applescript snippets or tutorials?

Thanks,

Jacob
     
Krusty
Professional Poster
Join Date: Oct 1999
Location: Always within bluetooth range
Status: Offline
Reply With Quote
Apr 26, 2003, 06:46 PM
 
on adding folder items to this_folder after receiving added_items
try
tell application "Finder"
activate
set the target_folder to folder "Desktop" of home
open folder "Desktop" of home
end tell
end try
end adding folder items to

This would work if your Safari downloads folder is your user desktop folder. You'll have to change the target folder name depending on where you actually have your folder.


If you're downloads directory is not in your home folder... obvoulsy you would not be able to use the "home" command that I've used in this script.

Also, this is just the mechanics of how to open the folder. If you attach it to your downloads folder, it will open a finder window ANYTIME you add an item (not just when Safari adds an item). If you have AppleScript studio installed (assuming 'yes' here) Check out Library/Scripts/Naviagation Scripts for good examples (Library being the main library folder, not the one in your user folder).

If you're still stuck .. give me more details of your variables and I may be able to craft one that will specifically suit your needs.

good luck
( Last edited by Krusty; Apr 26, 2003 at 07:00 PM. )
     
Krusty
Professional Poster
Join Date: Oct 1999
Location: Always within bluetooth range
Status: Offline
Reply With Quote
Apr 26, 2003, 07:18 PM
 
actually, I just found that the "reveal" command works just as well.

on adding folder items to this_folder after receiving added_items
try
tell application "Finder"
activate
reveal added_items
end tell
end try
end adding folder items to
     
immsav  (op)
Fresh-Faced Recruit
Join Date: Dec 2002
Location: Oxford
Status: Offline
Reply With Quote
Apr 26, 2003, 08:29 PM
 
Thanks, Krusty.

I just tried your second Applescript, and it works great. (Safari takes over and pushes the Finder window to the back, but I can cope with that.)

Any tips on which sites or books I should checkout to learn Applescript?

Thanks again,
Jacob
     
Krusty
Professional Poster
Join Date: Oct 1999
Location: Always within bluetooth range
Status: Offline
Reply With Quote
Apr 26, 2003, 08:40 PM
 
Originally posted by immsav:

Any tips on which sites or books I should checkout to learn Applescript?
Not really. I'm not any sort of "hard core" applescripter and I've never used a book ... only write them on rare occasion and usually I just try to find a sample script that has elements of what I need and ... well, just sorta wing it. Someone else may have better advice.

p.s. noticed that problem with the window opening and then returning to the back ... I can't remember the command but I KNOW you can do something to force it back to the front.
     
immsav  (op)
Fresh-Faced Recruit
Join Date: Dec 2002
Location: Oxford
Status: Offline
Reply With Quote
Apr 26, 2003, 11:45 PM
 
Thanks again, Krusty. Does anyone else know how to force a window to front?
     
   
 
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
Top
Privacy Policy
All times are GMT -4. The time now is 04:16 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,