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 > Mac OS X > Can Folder Actions do this for me?

Can Folder Actions do this for me?
Thread Tools
Junior Member
Join Date: Jan 2002
Status: Offline
Reply With Quote
Nov 2, 2003, 03:28 PM
 
I have my Safari downloads configured to go into my Desktop folder. However, I'd like to automatically move all PDFs to a separate folder (say Desktop/PDFs), and THEN open them from there. Safari is configured to open the PDFs as soon as they're downloaded, but I'd like it to wait until the file is moved before it is opened.

Can anyone help me set this up?

Thanks!
     
Professional Poster
Join Date: Oct 1999
Location: Always within bluetooth range
Status: Offline
Reply With Quote
Nov 2, 2003, 06:05 PM
 
Originally posted by Propofol:

Can anyone help me set this up?

Thanks!
You can set up an Applescript that will selectively move pdf's to a new folder and then open them. HOWEVER ... if you have "Open safe files after downloading" checked on .. it would open the pdf before you had a chance to copy it.

The only solution I see for you is to turn off "Open safe files after downloading" completely ... but then you'll have to write the script such that
If filetype is pdf then move and open file
Else if its not a pdf, then open file.

In other words, you'll have to set up the script to manually deal with ALL things Safari downloads in order to get it to treat pdfs differently than non-pdfs. Make sense ??
     
Junior Member
Join Date: Jan 2002
Status: Offline
Reply With Quote
Nov 2, 2003, 07:45 PM
 
Yes,

I'll get on it now and post my results for others to see. Thanks!
     
Mac Elite
Join Date: Sep 2000
Location: Los Angeles
Status: Offline
Reply With Quote
Nov 2, 2003, 08:25 PM
 
You could also leave Open safe files... on and change your download folder to Desktop/PDFs. Then just write a script that moves everything BUT PDFs from that folder to your Desktop.
     
Mac Elite
Join Date: May 2002
Location: New York City
Status: Offline
Reply With Quote
Nov 2, 2003, 08:38 PM
 
I have a script that automatically moves PDFs to my Documents folder. Safari opens them on download, but they are still moved to the Documents folder.

Here's what I use:

Code:
on adding folder items to this_folder after receiving these_items try repeat with i from 1 to number of items in these_items set this_item to item i of these_items set the item_info to the info for this_item if the name extension of the item_info is "pdf" then tell application "Finder" to move these_items to folder "Documents" of folder "zachs" of folder "Users" of startup disk end if end repeat on error error_message number error_number if the error_number is not -128 then tell application "Finder" activate display dialog error_message buttons {"Cancel"} default button 1 giving up after 120 end tell end if end try end adding folder items to
Replace "zachs" with your short user name.
     
Professional Poster
Join Date: Oct 1999
Location: Always within bluetooth range
Status: Offline
Reply With Quote
Nov 2, 2003, 09:09 PM
 
Originally posted by zachs:
I have a script that automatically moves PDFs to my Documents folder. Safari opens them on download, but they are still moved to the Documents folder.
Hmmm ... so that actually works ? I was just guessing that it wouldn't work via an applescript since it would be in use by Safari already. But hey, if it works .. it works

Actually aaanorton's idea sounds like a good one as well. The desktop is used so commonly, it makes sense to attach the script to a lesser used folder (eg a dedicated "downloads" folder) and selectively copy back OUT to the desktop. Otherwise .. how would you ever be able to simply place a pdf on the desktop without it being whisked away immediately ?
     
Posting Junkie
Join Date: May 2001
Location: Brisbane, Australia
Status: Offline
Reply With Quote
Nov 3, 2003, 05:25 AM
 
Originally posted by zachs:
I have a script that automatically moves PDFs to my Documents folder. Safari opens them on download, but they are still moved to the Documents folder.

Here's what I use:


< code >

Replace "zachs" with your short user name.
I got a syntax error on the last line.

Syntax Error
A property can't go after this identifier.
end [adding folder] items

[ ] = selection.

PS. The Make new apple script Service is excellent in combination with web forums

[ fb ] [ flickr ] [] [scl] [ last ] [ plaxo ]
     
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
Nov 3, 2003, 05:45 AM
 
<snip>
     
Sal
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status: Offline
Reply With Quote
Nov 3, 2003, 11:55 AM
 
Originally posted by zachs:
I have a script that automatically moves PDFs to my Documents folder. Safari opens them on download, but they are still moved to the Documents folder.

Here's what I use:

Code:
on adding folder items to this_folder after receiving these_items try repeat with i from 1 to number of items in these_items set this_item to item i of these_items set the item_info to the info for this_item if the name extension of the item_info is "pdf" then tell application "Finder" to move these_items to folder "Documents" of folder "zachs" of folder "Users" of startup disk end if end repeat on error error_message number error_number if the error_number is not -128 then tell application "Finder" activate display dialog error_message buttons {"Cancel"} default button 1 giving up after 120 end tell end if end try end adding folder items to
Replace "zachs" with your short user name.


Good work! A couple things:

1) use the generic term "home" instead of hard-coding the path
2) the logic was a bit off in the repeat and it was attempting to move the entire group of items each time

Code:
on adding folder items to this_folder after receiving these_items try repeat with i from 1 to number of items in these_items set this_item to item i of these_items set the item_info to the info for this_item if the name extension of the item_info is "pdf" then tell application "Finder" to move this_item to folder "Documents" of home end if end repeat on error error_message number error_number if the error_number is not -128 then tell application "Finder" activate display dialog error_message buttons {"Cancel"} default button 1 giving up after 120 end tell end if end try end adding folder items to
     
Junior Member
Join Date: Jan 2002
Status: Offline
Reply With Quote
Nov 3, 2003, 07:16 PM
 
OK, the following script does what I wanted it to - it changes the location to the "Safari DownloadsDFs" folder, and then it opens the file. For all other file types, it simply opens the file with the appropriate application. As Krusty mentioned all files must be opened by the script, and therefore the Safari option "Open safe files after downloading" must be disabled.

Thanks to all who responded!

--------------------------------------
Code:
on adding folder items to this_folder after receiving these_items try repeat with i from 1 to number of items in these_items set this_item to item i of these_items set the item_info to the info for this_item if the name extension of the item_info is "pdf" then tell application "Finder" to move this_item to folder "Safari Downloads:PDFs" of desktop tell application "Finder" to open this_item else tell application "Finder" to open this_item end if end repeat on error error_message number error_number if the error_number is not -128 then tell application "Finder" activate display dialog error_message buttons {"Cancel"} default button 1 giving up after 120 end tell end if end try end adding folder items to
     
Mac Elite
Join Date: May 2002
Location: New York City
Status: Offline
Reply With Quote
Nov 3, 2003, 07:44 PM
 
Originally posted by Sal:
Good work! A couple things:

1) use the generic term "home" instead of hard-coding the path
2) the logic was a bit off in the repeat and it was attempting to move the entire group of items each time

1. Yeah, I was trying "home folder", which wasn't working. So now I know it's just "home".

2. You didn't change anything? Do you have any suggestions on how to do it better?
     
   
Thread Tools
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 04:21 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2