2019-08-20T14:16:41ZFluxBBhttps://macscripter.net/viewtopic.php?id=47025You're right Shane but double clicking upon an icon is my preferred protocol.

I never understood why Folder Actions Setup.app which was stored as "/Applications/Applescript/Folder Actions Setup.app/" was 'hidden' into "/System/Library/CoreServices/Applications/Folder Actions Setup.app/"

on treatPDF(anItem, this_folder)set targetFolder tomy buildFolder(this_folder, "treated PDFs")
# now we may move the PDF into targetFolder and treat the moved fileend treatPDF

on treatIworkDoc(anItem, this_folder, itsID)set targetFolder tomy buildFolder(this_folder, "treated iWork docs")
# itsID allow us to select the correct tratment to apply
# now we may move the iWork doc into targetFolder and treat the moved fileend treatIworkDoc

on treatPicture(anItem, this_folder, itsID)set targetFolder tomy buildFolder(this_folder, "treated Pictures")
# itsID allow us to select the correct tratment to apply
# now we may move the picture file into targetFolder and treat the moved fileend treatPicture

on buildFolder(this_folder, folderName)set destinationFolder to (this_folder as text) & folderName & ":"tell application "Finder"ifnot (exists folder destinationFolder) then
make new folder at this_folder with properties {name:folderName}endifendtellreturn destinationFolder as aliasend buildFolder

The two first instructions (enabled) are used to test the script after disabling the instructions:

on adding folder items to this_folder after receiving these_items
end adding folder items to

]]>https://macscripter.net/profile.php?id=139352019-08-20T09:41:29Zhttps://macscripter.net/viewtopic.php?pid=197289#p197289Thank you Peavine

At first I wrote a code supposed to gather the three protocols in a single one but when it was finished I remember that folder actions must be saved as scripts, not as applications.

With the asked question, the answer was simple because we are supposed to drop a folder into the hot folder (the one to which the script is attached).When we have to treat dropped files, we must remember what is written in the guide:

A well written Folder Action script leaves the hot folder empty. This avoids repeated application of the action to the same files, and allows Folder Actions to perform more efficiently.

]]>https://macscripter.net/profile.php?id=139352019-08-20T07:29:09Zhttps://macscripter.net/viewtopic.php?pid=197288#p197288Yvan. Thanks for posting the folder actions script. I never really understood how they worked but with a good example everything became clear. I've never much cared for droplets , which I found cumbersome to use, but folder actions scripts are much more flexible and easy to use.

Probably the hardest part is getting access to the setup app. I ended up making a one-line AppleScript to start it.]]>https://macscripter.net/profile.php?id=569342019-08-20T00:43:00Zhttps://macscripter.net/viewtopic.php?pid=197285#p197285I tried an alternate scheme.

(1) Create a droplet which may do the job two ways, (a) running the script offer the choose folder dialog (b) dropping a folder onto the icon of the script saved as an application

Applescript:

on runset sourceFolder to choose folder default location (path to home folder)
Germaine(sourceFolder)end run

on open seltell application "Finder"set theClass to class of (get properties of (item 1 of sel))if theClass is folder thenmy Germaine(item 1 of sel)endifendtellend open

on Germaine(sourceFolder)set stopCharacters to"_X"set stopCharacterCount to (count stopCharacters)tell application "Finder"set sourceFiles to (every file in sourceFolder ¬whose name contains stopCharacters and name endswith"pdf") as alias listendtell

Applescript:

on adding folder items to this_folder after receiving these_items-- CHECK FOR THE DESTINATION FOLDER WITHIN THE ATTACHED FOLDER-- IF IT DOESN'T EXIST, THEN CREATE ITset sourceFolder to (item 1 of these_items)

set stopCharacters to"_X"set stopCharacterCount to (count stopCharacters)tell application "Finder"set sourceFiles to (every file in sourceFolder ¬whose name contains stopCharacters and name endswith"pdf") as alias listendtell

Thank you very much, you are a life saver!]]>https://macscripter.net/profile.php?id=579422019-08-19T18:29:38Zhttps://macscripter.net/viewtopic.php?pid=197274#p197274ttokunaga. It's a bit difficult to do this without having the ability to test the script in Hazel, but I believe the following will do what you want. If many files are involved, the script could be slow.

Is there a way to leave out having to set a location and have it process all files within subfolders as well? At the moment it will only work with files within "main folder"]]>https://macscripter.net/profile.php?id=579422019-08-19T16:11:08Zhttps://macscripter.net/viewtopic.php?pid=197272#p197272ttokunaga. You can avoid the choose-folder prompt by specifying a target folder in the script. To do this, delete the following line:

Applescript:

set sourceFolder to choose folder default location (path to home folder)

And, insert into its place the following (but with the desired folder path):

I was wondering if there is a way to make it so I don't get a prompt to choose the folder i want the script to run on.

I made a hot folder in Hazel where you can drop these pdfs in and it's supposed to automatically run this script to rename these without having to choose a folder or hit play in the script editor.

Ideally I would like to just drop the files in and let the script do its job without any intervention.

Thank you very much for the help!]]>https://macscripter.net/profile.php?id=579422019-08-19T14:03:27Zhttps://macscripter.net/viewtopic.php?pid=197270#p197270ttokunaga. I'm pretty sure that both of my scripts work as you want. Just to demonstrate, I wrote the following script, which renames all PDF files with _X in their file name in a folder you select. I tested this on three files with the names you specify as examples and the script renamed these files as expected.