Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Stop folder action from repeating

I have set up a folder action that adds a suffix (_HR) to pdf files that are dropped into it but the problem is it keeps repeating the action on the same file so you end up with filenameHR_HRHR.pdf

How do you stop the action repeating on files it has already processed?

MacPro 2.93 Ghz Quad, Mac OS X (10.5.7)

Posted on Jul 23, 2009 10:11 AM

Reply
2 replies

Aug 7, 2013 2:48 AM in response to Bobby Dazzler

Or you could code a little trap in the script to not process files with a given suffix. Here's one of mine which tests for the suffix "_crtolf"




-- Script to translate CR to LF as a folder action

-- Julian Jordan 06/08/2013



on adding folder items to this_folder after receiving added_items


try


repeat with i from 1 to number of items in added_items

tell application "Finder"

set this_item to item i of added_items

set the item_info to the info for this_item

set the the_file_name to the name of this_item



set the folder_name to the name of this_folder

set nameExt to name extension of (item i of added_items)

set oldName to text -((count nameExt) + 8) through -((count nameExt) + 2) of (get name of (item i of added_items))


--Don't process new file we've just made - otherwise endless loop

if (oldName ≠ "_crtolf") then

set theUnixPath to POSIX path of (item i of added_items)

set theShellString to "tr '\\r' '\\n' < " & quoted form of (theUnixPath) & " > " & quoted form of (theUnixPath & "_crtolf.txt")

do shell script theShellString

end if


end tell

end repeat


end try



end adding folder items to

Stop folder action from repeating

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.