|
|
try this
try this
That looks like it will work but there is an easier way. Try adding this line instead of what you did: set folderLocation to (container of (path to desktop folder) as string) & "Pictures:unfiled:" So your script will end up like this: on adding folder items to this_folder after receiving added_items
tell application "Finder"
-- Here is the magic statement we added
set folderLocation to (container of (path to desktop folder) as string) & "Pictures:unfiled:"
  repeat with aFile in added_items
  if the name of aFile contains {".jpg"} ¬
  or the name of aFile contains {".gif"} ¬
  or the name of aFile contains {".png"} ¬
  or the name of aFile contains {".pict"} ¬
  or the name of aFile contains {".tiff"} ¬
  or the name of aFile contains {".gif"} ¬
  or the name of aFile contains {".psd"} ¬
  or the name of aFile contains {".bmp"} then
 tell application "Finder"
 try
-- This next line is also changed
   move aFile to folder folderLocation
    on error err
     display dialog err
  end try
 end tell
 display dialog ¬
"Image files have been moved to the Unfiled folder in your Pictures folder."
 end if
end repeat
end tell
end adding folder items to
that is MUCH better... :)
thanx!
try this
By the way, I believe that you can change this complicated (and possibly slower) code: Â Â if the name of aFile contains {".jpg"} ¬
  or the name of aFile contains {".gif"} ¬
  or the name of aFile contains {".png"} ¬
  or the name of aFile contains {".pict"} ¬
  or the name of aFile contains {".tiff"} ¬
  or the name of aFile contains {".gif"} ¬
  or the name of aFile contains {".psd"} ¬
  or the name of aFile contains {".bmp"} then
To this much simpler (and possibly faster) code: Â Â if the name extension of aFile is in {"jpg", "gif", "png", "pict", ¬
  "tiff", "gif", "psd", "bmp"} ¬
  then
I'm pretty sure that filtering using a list produces a faster script than using a complicated if...then statement.
try this
I tried to write something like this but couldn't get it to work.
try this
I just tested all of the modifications listed above and here is a script that works fine: on adding folder items to this_folder after receiving added_items
tell application "Finder"
set homeFolder to (container of (path to desktop folder) as string)
set folderLocation to homeFolder & "Pictures:unfiled:"
repeat with aFile in added_items
if the name extension of aFile is in ¬
{"jpg", "gif", "png", "pict", "tiff", "gif", "psd", "bmp"} then
tell application "Finder"
try
move aFile to folder folderLocation
on error err
display dialog err
end try
end tell
end if
end repeat
display dialog ¬
"Image files have been moved to the Unfiled" & return & ¬
"folder in your Pictures folder."
end tell
end adding folder items to
If this doesn't work for you then make sure that you have run the "Enable Folder Actions" script and have successfully attached a folder action to the folder you want this script to run from. For a good reference on how to get it all to work see Apple's web page on Folder Actions.
try this
I moved the dialoge box telling me that image files had been moved because it was saying it no matter what I added..
try this
Heh, whups. I thought you meant that you couldn't get my modifications to work. I see now that you were just saying that you had problems with writing something similar to what I used. if the name of aFile contains {".jpg"} then
and this one: if the name extension of aFile is in {"jpg", "gif", "png"} then
are the keywords contains and is in. if the name of aFile contains {".jpg", ".gif", ".png"} then
The only thing that would match would be a file named "myfile.jpg.gif.png", or any file with all of those somewhere in it.
try this
The entire first block of "set" statements in the code above can now be replaced by:
set unfiledpictures to ((path to pictures folder as text) & "unfiled:")From the release notes: "The path to command now has the following new folder constants: applications folder, documents folder, favorites folder, home folder, library folder, movies folder, music folder, pictures folder, public folder, shared documents, shared documents folder, sites folder, utilities folder."
try this
You know, I have been wanting a path to home folderstatement for so long! The statement: (container of (path to desktop folder)works but it is a lot more cumbersome and less obvious. I'm glad they expanded the options that the path command gives you, it really helps out. |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.17 seconds |
|