Stop folder action from repeating
How do you stop the action repeating on files it has already processed?
MacPro 2.93 Ghz Quad, Mac OS X (10.5.7)
MacPro 2.93 Ghz Quad, Mac OS X (10.5.7)
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