Single click folder action script
Hi
Long shot question here:
I am wanting to set up a folder action script that is activated by only single clicking a folder (selecting), very much the same as "Macintosh HD:Library:Scripts:Folder Action Scripts:open - show comments in dialog.scpt", the dialog will display when the folder is selected, not opened.
Is this possible with applescript, or a combination of AS and "do shell script"? if so can I get some pointers please.
Cheers
Budgie
Hello
The Standard additions dictionary claims:
adding folder items to: Called after new items have been added to a folder, but only when the folder’s window is open
adding folder items to alias -- Folder receiving the new items
after receiving a list of alias -- a list of the tems the folder received
closing folder window for: Called after a folder window has been closed
closing folder window for alias -- the folder that was closed
moving folder window for: Called after a folder window has been moved or resized
moving folder window for alias -- the folder whose window was moved or resized
from bounding rectangle -- the previous coordinates of folder window (you can get the new coordinates from the Finder)
opening folder: Called after a folder has been opened into a window
opening folder alias -- the folder that was opened
removing folder items from: Called after items have been removed from a folder, but only when the folder’s window is open
removing folder items from alias -- the folder losing the items
after losing a list of alias -- a list of the items the folder lost. For permanently deleted items, only the names (in strings) are provided.
Other actions , like single click, are NOT treated.
Yvan KOENIG (from FRANCE dimanche 29 janvier 2006 19:12:18)
Similar Messages
-
Need a Folder Action Script to automate running of Applescripts in iTunes
I posted this in the OSX forum but thought i'd try here too:
I have a couple of applescripts that I have begun using on some of my podcasts. Specifically they will deselect "Skip When Shuffling" and "Remember Track Position" (Thanks Doug!). I feel like it is getting tedious to have to remember to run these scripts every time the Podcast updates a new episode. I'm looking for a folder action script that will run these applescripts whenever a new item is added to their folder. While I try to puzzle one together (having never written one) does anyone have anything to fit these needs?Yes.
I recently need one to do something else.
I'll just give you the script I am using, you can hack at will...
property TargetPlaylist : "Library"
on adding folder items to this_folder after receiving added_items
repeat with each_item in added_items
tell application "iTunes"
add each_item to playlist TargetPlaylist
end tell
end repeat
tell application "Finder"
move every item of this_folder to the trash
empty the trash
end tell
end adding folder items to
This script when attached as a folder action will add the items dropped into it to my iTunes library, then delete them.
You can easily tear this one apart to get what you need done.
Beavis2084 -
Single click folder name to expand folder in folder view?
As with prior versions, in [Windows] Explorer's main window, you can enable hovering to select and single clicking to expand the folder (but that is a pain in the rear when working with files). Windows XP folder view nicely allowed single clicking the folder name to expand the folder. Was that removed from Windows 7? Looks like the only way to expand a folder in folder view is to either click on the small plus sign or to double click on the folder name. Or is there a switch somewhere I am missing? Thanks.
"...Things are worse than that now... When you single click on a folder name in the folder list, the folder contents show in the right hand file window, as usual. But, when you use an arrow key to move to a folder name in the folder list, the folder
contents no longer show in the right hand file window...."
The option seems to be disabled. It is in Explorer>tools>folder options>navigation pane>"automatically expand to current folder" (win7 v6.1
Excluding this extremely useful feature really cripples Win7Explorer. I was spoiled by w9x and XP explorers. I am new to MS forums. Is there a moderated microsoft forum where this question can be posted, in the hope that a patch is produced?
I asked this in 2007 and I was answered <<WE DON'T GIVE A SH*T OF WHAT YOU WANT>>
See here:
http://connect.microsoft.com/WindowsServerFeedback/feedback/details/313066/explorer-should-expand-folder-tree-the-windows-xp-way -
Folder Actions script no longer runs on new file creation
Hope this isn't trivial.......first time posting here...hopefully in the right place.I'm not a total Mac OS X newbie...and surely no techie, either. Dabbled a wee bit with Automator and scratchin' my head on this one. Help, please!
Any idea why folder actions not running when a new file is saved? A simple add-color-label script created in Automator was workin' fine before I did a Snow Leopard-to-Leopard downgrade clean-install & account migration from external HD (TimeMachine) backup. Folder actions are enabled and script runs only if I start it with Automator Runner. Previously, it would label the file as soon as I saved it....now it needs a manual start. Is this default behavior in Leopard? Or am I missing something or doin' something wrong? Or is this a consequence of downgrade? I was sure I had the same script workin ok in my original Leopard install - though possibly un-modified at that time.
I have no clue why, but the new version I created recently (cpl wks ago?)worked the first time I added a new file but not thereafter...and in that instance it only labelled the file in Finder upon quitting Preview (file is a Grab saved as pdf).
The reason for the downgrade was compatibility problems with Photoshop CS4 on SL (OS & app all updated yet crashin' at the drop of a hat) - maybe due to lack of RAM? (only 1GB). Saw quite a few posts regarding SL running CS4 problems, so now I'm back to running 10.5.8 ..again.. and PS actually runs smooth like it did before.
Maybe these console messages are a help......or am I barkin' up the wrong tree?
6/11/11 7:44:54 PM /System/Library/CoreServices/Folder Actions Dispatcher.app/Contents/MacOS/Folder Actions Dispatcher[91] CPSGetProcessInfo(): This call is deprecated and should not be called anymore.
6/11/11 7:44:54 PM /System/Library/CoreServices/Folder Actions Dispatcher.app/Contents/MacOS/Folder Actions Dispatcher[91] CPSPBGetProcessInfo(): This call is deprecated and should not be called anymore.
6/11/11 7:44:54 PM /System/Library/CoreServices/AppleScript Runner.app/Contents/MacOS/AppleScript Runner[264] CPSGetFrontProcess(): This call is deprecated and should not be called anymore.
6/11/11 8:19:12 PM Automator Runner[415] Error while processing arguments
6/11/11 8:20:31 PM /Applications/AppleScript/Folder Actions Setup.app/Contents/MacOS/Folder Actions Setup[420] CPSGetProcessInfo(): This call is deprecated and should not be called anymore.
6/11/11 8:20:31 PM /Applications/AppleScript/Folder Actions Setup.app/Contents/MacOS/Folder Actions Setup[420] CPSPBGetProcessInfo(): This call is deprecated and should not be called anymore.
6/11/11 8:20:32 PM [0x0-0x5b05b].com.apple.systemevents[421] com.apple.FolderActions.enabled: Already loaded
And for that matter....why does Automator throw these messages? All apps (except iWork '08 apps) and OS are up to date.
- Just a few of the many actions not loaded:
6/11/11 7:48:25 PM Automator[294] The action “Start iTunes Visuals” could not be loaded because the application “iTunes” is the wrong version.
6/11/11 7:48:25 PM Automator[294] The action “Stop iTunes Visuals” could not be loaded because the application “iTunes” is the wrong version.
6/11/11 7:48:25 PM Automator[294] The action “Update iPod” could not be loaded because the application “iTunes” is the wrong version.
6/11/11 7:56:33 PM Automator[294] name = name was not found
6/11/11 7:56:33 PM Automator[294] name = name extension was not found
6/11/11 7:56:33 PM Automator[294] name = file type was not found
6/11/11 8:00:29 PM Automator Runner[339] Error while processing arguments
6/11/11 8:00:30 PM Automator Runner[339] The action “Import Files into iTunes” could not be loaded because the application “iTunes” is the wrong version.
6/11/11 8:00:30 PM Automator Runner[339] The action “Add Songs to iPod” could not be loaded because the application “iTunes” is the wrong version.
6/11/11 8:00:30 PM Automator Runner[339] The action “Add Songs to Playlist” could not be loaded because the application “iTunes” is the wrong version.
6/11/11 8:00:30 PM Automator Runner[339] The action “Apply SQL” could not be loaded because the application “Xcode” was not found.
Do I need to wipe the drive again and re-install everything?
Any help is greatly appreciated. Apologies if this seems long-winded.Folder Actions are set up a bit differently in Leopard (they use an AppleScript wrapper), and several actions have been updated to use new technologies available in Snow Leopard. Looking at some of your console logs, it looks like some actions or workflows were just copied over from Snow Leopard. When changing versions like that, you should rebuild the workflows so that they link to the correct actions, and check added actions for any dependencies (an action won't be loaded if it requires resources that are not available).
Resaving your Folder Action workflow as a Folder Action Plug-in should do the trick. -
Customize Folder Action and Email script
I have been adapting the below script so if I drop a file on the script, the file will be emaild to the default address. But, I can't figure out how to customize the two below easy tasks into this script. Thanks for any help out there!
1. A file is moved into folder1 triggers the script.
2. After the file is email'd I would like it to be moved into folder 2. I have found a script in this forum that moves the file, but I don't know where to add it.
on adding folder items to theFolder after receiving theAddedItems
tell application "Finder"
move theAddedItems to folder "G5:Users:camille:Desktop:folder2:"
end tell
end adding folder items to
The Send File Script that I have been adapting (concept and initial coding by Paul Van Cotthem):
property this_folder : "G5:Users:camille:Desktop:folder1"
property emailAddress : "[email protected]"
global sendAction
on open fileList
-- If one prefers to test for folders before the files are created, the enable this code.
repeat with filePath in fileList
if (filePath as string) ends with ":" then
display dialog "Please drop only files, not folder." buttons {"OK"} default button 1 with icon 0
return
end if
end repeat
enterAddress()
repeat with filePath in fileList
set filePath to filePath as string
if filePath does not end with ":" then -- it's a file
tell application "Finder" to set fileName to name of item filePath
tell application "Microsoft Entourage"
-- This code is faster, but if the user trashed the attached files before sending them, Entourage cannot send the attachtments.
make new outgoing message at out box folder with properties {recipient:emailAddress, subject:fileName, attachment:filePath}
-- This code is slower, but attached files are saved into Entourage's message database immediately.
set theSubject to "File attached: " & fileName
set newmsg to make new draft window with properties ¬
{recipient:{address:emailAddress, recipient type:to recipient}, subject:theSubject, content:theSubject, attachment:filePath}
send newmsg
end tell -- Entourage
end if -- file or folder?
end repeat -- filePath
end open
on run
enterAddress()
end run
on enterAddress()
display dialog "Send to:" buttons {"Cancel", "Send now"} with icon note ¬
default button 2 default answer emailAddress giving up after 2
set dialogResult to result
set sendAction to button returned of dialogResult
set emailAddress to text returned of dialogResult
end enterAddress
G5 Mac OS X (10.3.9)
G5 Mac OS X (10.3.9)
G5 Mac OS X (10.3.9)
G5 Mac OS X (10.3.9)Go ahead and put that chunk of code on a new line at the very bottom of your script. Then between the on adding folder items to theFolder after receiving theAddedItems line and the tell application "Finder" line, insert the word open on a line by itself.
By putting the term "open" there you are telling the script to run all the code in the "on open" block when triggered by the folder action handler. To make the folder action active you'll need to save the droplet in your ~/Library/Scripts/Folder Action Scripts folder, and then you'll need to attach it to something by control-clicking the desired folder and/or using the Folder Action Setup Utility to connect script to folder. -
Need help with simple folder action or script
I have created an export preset in Lightroom that exports images to a folder called "To Email" on my hard drive, and then automatically attaches those images to a new email in my email client (Mailplane).
It's a great solution that allows me to send a photo via email with one click from Lightroom. However, I want to take it a step further by creating a folder action or script that automatically deletes the image after it is attached to the email. This will allow me to put the folder somewhere deeper in my file system without having to worry about cleaning it out all the time.
Unfortunately, I have no experience with Automator or AppleScript. Can you help? Thanks.I think you need to rework elements of your workflow.
For example, you say the export preset creates and sends the email.
If this is the case, the the logical place to make your change would be to edit that preset action (I don't have Lightroom to know whether this is an option there or not).
The problem with using a Folder Action is that the Folder Action will trigger when the file is dropped in the folder, but that will be before the email is generated or sent, so you run the risk of deleting the file before it's sent.
So if you can't edit the export preset to do the deletion I would suggest decoupling the 'send an email' and 'delete file' elements from the Lightroom action - in other word change Lightroom to just export the file, and have a separate folder action that triggers when files are added to that folder. The folder action script can take care of generating the email and sending it out, knowing when the email is sent and therefore when it's safe to delete the file.
WIthout seeing more of the current workflow it's not easy to be more specific. -
Script Help: Folder Actions - Move files
Hi,
So, I'm having some trouble writing a script for a folder action. I basically want the folder to check the file extension of the files that I add to the folder, and if they are music files (mp3, m4a, m4p), to move those files to a different folder. Additionally, is it possible to also move entire folders containing music files to a different folder, instead of just single files?
Thank you for any help.What is your script doing now (note that a name extension does not include the period delimiter)? You can move entire folders, but your folder action script would only pass the items added to the attached folder, not any folder contents. Your folder action script would need to look into any passed folders if you wanted to move them based on their contents.
-
Script works in Script Debugger, but not a folder action - can u help?
Hi
I have written the following script to run as as folder action and it works fine when running it through in debug mode in Script Debugger, but as a folder action nothing happens.
I wonder if someone could have a look and spot what the problem is.
Thanks
Nick
on adding folder items to this_folder after receiving added_items
set convertPath to "Macintosh HD:opt:local:bin:ffmpeg"
tell application "Finder"
set inPath to this_folder as alias
set outPath to this_folder as alias
set filesToConvert to (name of every item of inPath whose name extension is "m4a")
end tell
repeat with i from 1 to count of filesToConvert
set fileName to removeExtension(item i of filesToConvert)
do shell script POSIX path of convertPath & " -i " & (quoted form of ((POSIX path of inPath) & item i of filesToConvert)) & " -f mp3 -ar 44100 -ab 192k -acodec libmp3lame " & (quoted form of (POSIX path of outPath)) & quoted form of (fileName & ".mp3") & " -mapmetadata " & (quoted form of ((POSIX path of inPath) & item i of filesToConvert)) & ":" & (quoted form of (POSIX path of outPath)) & quoted form of (fileName & ".mp3")
end repeat
end adding folder items to
to removeExtension(fileToParse)
#display dialog fileToParse
set prevTIDs to text item delimiters of AppleScript
set text item delimiters of AppleScript to "."
return first text item of fileToParse
set text item delimiters of AppleScript to prevTIDs
end removeExtensionmmh, well, it seems something is awry with the triggering. other folder action scripts seemed to work fine, but now are intermittent.
i created the following simple script:
on adding folder items to this_folder after receiving added_items
display dialog "1"
end adding folder items to
sometimes it works, sometimes not.
what could be going wrong? -
Folder action to find and replace text and change line feeds
I want to use a folder action to find and replace text and change Mac carriage returns to DOS line feeds inside text files.
The text to be replaced is: "/Users/wim/Music/iTunes/iTunes Music/Music" (without the quotes)
This text has to be removed (i.e. replaced by an empty string)
The text occurs many times within each file.
The files are playlists exported from iTunes in the M3U format (which are text files). They contain Mac carriage returns. These need to be changed to DOS line feeds.
I have found the following two perl commands to achieve this:
To find and replace text: perl -pi -w -e 's/THIS/THAT/g;' *.txt
To change carriage returns to line feeds: perl -i -pe 's/\015/\015\012/g' mac-file
I know that it's possible to make a folder action with Automator that executes a shell script.
What I want to do is drop the exported playlists in M3U format in a folder so that the folder action will remove the right text and change the carriage returns.
My questions are:
Is it possible to make a folder action that executes command line commands instead of shell scripts?
What is the correct syntax for the two commands when used in a folder action shell script? Especially, how do I escape the slashes (/) in the string to be removed?
Thanks for your helpOk, I've include an applescript to run a shell command. The applesript command quoted form makes a string that will end up as a single string on the bash command line. Depending on what you want to do, you may need multiple string on the bash command lines. I've included some information on folder actions.
It is easier to diagnose problems with debug information. I suggest adding log statements to your script to see what is going on. Here is an example.
Author: rccharles
For testing, run in the Script Editor.
1) Click on the Event Log tab to see the output from the log statement
2) Click on Run
For running shell commands see:
http://developer.apple.com/mac/library/technotes/tn2002/tn2065.html
on run
-- Write a message into the event log.
log " --- Starting on " & ((current date) as string) & " --- "
-- debug lines
set desktopPath to (path to desktop) as string
log "desktopPath = " & desktopPath
set unixDesktopPath to POSIX path of desktopPath
log "unixDesktopPath = " & unixDesktopPath
set quotedUnixDesktopPath to quoted form of unixDesktopPath
log "quoted form is " & quotedUnixDesktopPath
try
set fromUnix to do shell script "ls -l " & quotedUnixDesktopPath
display dialog "ls -l of " & quotedUnixDesktopPath & return & fromUnix
on error errMsg
log "ls -l error..." & errMsg
end try
end run
How to set up a folder action.
1) right click on folder. click on Enable folder actions
2) Place script in
/Library/Scripts/Folder Actions Scripts
3) right click on folder. click on attach folder action
pick your script.
Create a new folder on the desktop & try.
You can put multiple folder actions on a folder. There are other ways of doing this.
Here is my test script:
on adding folder items to this_folder after receiving dropped_items
repeat with dropped_item_ref in dropped_items
display dialog "dropped files is " & dropped_item_ref & " on folder " & this_folder
end repeat
end adding folder items to
How to make the text into an AppleScript program.
Start the AppleScript Editor
/Applications/AppleScript/Script Editor.app
In Snow Leopard it's at: /Applications/Utilities/AppleScript Editor
Copy the script text to the Applescript editor.
Note: The ¬ is typed as option+return. ption+return is the Applescript line continuation characters.
You may need to retype these characters.
Save the text to a file as an script and do not check any of the boxes below. -
Applying a folder action to thousands of folders?
I am pulling my hair out with this; I need to know the best way to do this. My client said he had "a thousand or so" eps files that he wanted bundled into specific groups, then duplicated as pdf, jpg, png and tif files, each group in its own subfolder with an excel file that lists each of the file names for each bundle. So, essentially, the structure would look something like this:
Archive of Files (all of them)Bundles (ie., singles or multiples)Type of Bundles (ie, 5, 10, 25, 50, 100, 200)Groups and excel file (ie, "62697200376 - 62697200380")Filename Folder (ie, "62697200376", "62697200377", "62697200378", etc)
filename.eps
filename.tif
filename.pdf
filename.jpg
filename.png
Insane.
Anyway, what he actually sent me was 99,997 files - not "a thousand or so". So now, thanks to applescripts and automator, I have managed to:
- separate the archive of files into bundles
- set up the types of bundles
- Group the files (no excel file just yet, that'll be last)
- run applescript to create a folder for each eps file and move that eps file into it's folder
- have a working (and tested) workflow that will duplicate and convert each eps file to a pdf and save that pdf to the same folder.
I also have folder actions that will duplicate the pdf files as tif, jpg, and png once the pdf file is saved.
How can I attach these folder actions to these folders? Specifically the filename folders? I know that you're supposed to select each folder one at a time and then click on "Folder Actions Setup" to choose the actions, but there are nearly 100,000 folders that I need to get these three actions attached to before I can run the workflow. I don't think I will survive the eminent implosion that I will suffer if I have to attach these folder actions to each of the 99,997 folders one at a time (and I definitely wouldn't meet my deadline of having all this done).Thank you all for the replies.
So, I know I'm doing something wrong, but I just can't seem to see it. In applescript editor, I have this (based on Camelot's script above):
tell application "Finder"
set theFolders to every folder of (choose folder) as alias list
end tell
tell application "System Events"
repeat with eachFolder in theFolders
try
attach action to eachFolder using "/Library/Scripts/Folder Action Scripts/Image - Duplicate as PNG.scpt"
end try
try
attach action to eachFolder using "/Library/Scripts/Folder Action Scripts/Image - Duplicate as JPG.scpt"
end try
try
attach action to eachFolder using "/Library/Scripts/Folder Action Scripts/Image - Duplicate as TIFF.scpt"
end try
end repeat
end tell
First, I tried it without the try / end try but it kept telling me that it didn't understand the attach action message. After I added the try / end try, it goes through but the actions do not get attached and I get an error number -1708 like this:
tell application "System Events"
attach action to alias "[removed]:Bundles:5:first copy:62697200376 - 62697200380:UPC (A).62697200376:" using "/Library/Scripts/Folder Action Scripts/Image - Duplicate as PNG.scpt"
--> error number -1708
attach action to alias "[removed]:Bundles:5:first copy:62697200376 - 62697200380:UPC (A).62697200376:" using "/Library/Scripts/Folder Action Scripts/Image - Duplicate as JPG.scpt"
--> error number -1708
attach action to alias "[removed]:Bundles:5:first copy:62697200376 - 62697200380:UPC (A).62697200376:" using "/Library/Scripts/Folder Action Scripts/Image - Duplicate as TIFF.scpt"
--> error number -1708
The folder "First Copy" is a backup I made of some of the files; there are 200 folders in there, each containing 5 subfolders, and in the subfolder is the actual eps file. I figure if I can make something work on this small backup I can make it work on the actual folders / subfolders. -
Folder Action Problems with Leopard 10.5.8
My company recently upgraded from 10.4.11 to 10.5.8 and our folder actions have been stopping mid-process or not working at all. Sometimes a few files will process and then everything stops completely.
Our workflow involves the use of several different hot folders that use folder actions (converting InDesign CS4 documents to various quality of PDFs). All of the actions are single stream, meaning each folder does the action it's assigned and the original file is trashed and the new file remains in the folder. There are no subsequent folder actions that pull from the newly processed files. We also only run one folder action (with several files dropped in it) at a time.
I have also tried running a pre-made generic folder action script from Apple and it, too will stop mid-process, process a few files then stop, or not work at all.
Does anyone know what might be causing this problem with either the new Applescript or Folder Actions with Leopard 10.5.8?I have several scripts that all work different ways. One script I have opens the InDesign document, exports a PDF to a different folder located elsewhere on the hard drive (where a different script searches for PDFs). After this the original document is sent to the trash. Nothing new is created in the original Folder Action Scripted folder.
What's more, even Apple's stock Folder Actions don't work properly and stop mid-process. I've seen vague reports of 10.5.8 having issues with Applescript or Leopard in general. The fact this script works perfectly in 10.4.11 makes me think that something has changed with the way Leopard handles the FA's. -
What does this simple folder action not work?
OK I have been playing with this all weekend. I just wanted a simple folder action to move a file from folder a to folder b. There is really not much to it. The workflow works just fine. "Somtimes" running the script runs the workflow.app. However when I drop a file into folder a - nothing happens. I have enabled folder actions. Can anyone help?
here is a pic of the relative screens that should help you.
http://flickr.com/photos/hawsnet/2605303472/sizes/l/
Thanks for any help you can provide.
PS I even stopped by my local Genius Bar -- they could not help.Vantive,
Try either:
*on adding folder items to this_folder after receiving added_items*
*tell application "Finder"*
*repeat with this_item in added_items*
*move this_item to folder "Folder B" of folder "Desktop" of folder¬*
*"MyShortName" of folder "Users" of the startup disk*
*end repeat*
*end tell*
*end adding folder items to*
Or:
*on adding folder items to this_folder after receiving added_items*
*tell application "Finder"*
*repeat with this_item in added_items*
*move this_item to "Macintosh HD:Users:MyShortName:Desktop:Folder B"*
*end repeat*
*end tell*
*end adding folder items to*
In either case replace MyShortName with your actual short name. +Make sure the script is saved to your Home/Library/Scripts/Folder Action Scripts folder.+ Then right-click or control-click on "Folder A" and, if necessary, select "Enable Folder Actions." If enabled, right-click or control-click on "Folder A" and select "Attach a Folder Action…" When the Choose-a-File window appears highlight the script and press Choose.
Both of the above scripts worked for me in testing. For what it's worth, both my /Library/LaunchAgents, and /System/Library/LaunchAgents folders are empty.
Good Luck...
Regards, Andrew99 -
Silly: but how do you remove a folder action
I love this thing, i just cant for the life of me find how to remove a folder action I made!!! lol. Can you help!
To remove it from the folder it's attached to, ctrl-click on that folder and scroll down to "Remove a folder action". To delete it entirely from your system, delete it from
yourname/Library/Scripts/Folder Action Scripts/
Cheers,
H -
I'm new to this group, and my question may have been answered a long time ago as I'm using OS 10.5.8. I've been teaching myself AppleScript, and have been using "AppleScript - The Missing Manual" by Adam Goldstein and "AppleScript 1-2-3" by Sal Soghoian and Bill Cheeseman. All has gone well until now. I'm working on a couple of folder actions and have hit a wall. I've successfully written "on opening..." and "on closing..." actions. However, I have been 100% UNsuccessful at writing "on adding folder items to..." scripts. Action scripts are saved in the proper location, are attached properly, and folder actions are enabled. I turned a primary "on adding..." script (one I started out to do) into a droplet, and it functions perfectly when files are dropped on it. Help in explaining to me "the error of my ways" would be appreciated.
If there is an error in a folder action script, it tends to fail silently - for example, your *opening folder* script will fail because you are not coercing theCount (a number) to text (display dialog doesn't like lists, which is what you are getting by concatenating a string to a number).
Since you have a droplet that works correctly, you can just add a folder action handler to that script. I use a folder action template that includes handlers so that it can be run and tested from the *Script Editor* (it can also be used as a droplet). In the following example, the doStuff handler is what does the stuff, and the other handlers (including the folder action) just pass items to it.
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
font-weight: normal;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px; height: 340px;
color: #000000;
background-color: #FFD891;
overflow: auto;"
title="this text can be pasted into the Script Editor">
on run -- application double-clicked or run from the Script Editor
tell application "Finder" to try
set someItems to (the selection) as alias list
on error errorMessage number errorNumber
set someItems to (the selection) as alias as list
end try
if someItems is {} then set someItems to (choose file with multiple selections allowed)
doStuff for someItems
return
end run
on open theFiles -- items dropped onto the application
doStuff for theFiles
return
end open
on adding folder items to this_folder after receiving these_items
handle items added to a folder
parameters - this_folder [alias]: the folder added to
these_items [list]: a list of items (aliases) added
returns nothing
doStuff for these_items
return
end adding folder items to
to doStuff for someFiles
do stuff with each file in someFiles
parameters - someFiles [list]: a list of files to do stuff with
returns nothing
repeat with anItem in someFiles
try
-- do stuff, for example:
tell application "Finder"
set theName to name of anItem
considering case -- case sensitive match
if "-P" is in theName then
move anItem to alias "HD:Users:myself:Property:All Property"
else if "-GP" is in theName then
move anItem to alias "HD:Users:myself:Photography:General Photos"
else
log "no match"
end if
end considering
end tell
on error errorMessage number errorNumber -- oops
log errorMessage
-- activate me
-- display alert "Error " & errorNumber message errorMessage
end try
end repeat
return
end doStuff
</pre> -
how can I get to this function?
Please read...
posted by Frank Caggiano
this should improve performance...
Right click on the file and select Services from the menu then Folder Actions Setup
This will open
Check to see which (if any) folders have actions. If you didn;t turn it on intntionally disable it.Hi deltone,
Although your product information says, "iMac 27", Mac OS X (10.6.8), 2.7 GHz Intel Core i5, 4GB 1333MHz", I'm guessing you are beyond that.
Here's why, folder actions have changed places. Check out this help from others (thanks to Barney-15E, VikingOSX and ChangeAgent).
Attaching folder action scripts not available i... | Apple Support Communities
Best Regards,
Nubz
Maybe you are looking for
-
I want. to blow. my brains out.
I am o frustrated with this program I could scream. My project has been fine as far as music for the past two weeks I've been working on it. Recently I've changed my password to my iTunes Apple ID account. Some of the songs I'm using for the project
-
Navigation setting in iPhoto 6
I have just installed iPhoto 6 and was in the edit mode trying out the different effects. A navigation bar appeared that would allow me to adjust the photo into the center of the matt effect. I closed the navigation bar and have not been able to find
-
Hi, I have a funny situation here. I am running 11i on windows server 2003. When i start the conc. managers the application hangs.( I mean i can not open the forms). And when i stop the conc. manager the hanged forms open immediately. This is on the
-
When I sync my i-phone contacts on MacBook Pro - it adds my contacts again (now I have 3 lots of the same contacts!). Is there a way to compress the contacts and only have one of each again?
-
Get the first photo in photo album
Hi, I am new to iphone programming. How can I get the first image in photo album into an UIImage object? I can not use the ImagePicker because this will the initial image when user launches the app. Thanks, fm