Monday, October 26, 2020

#1 2020-09-24 09:51:52 am

Pugurugu
Member
Registered: 2020-09-10
Posts: 3

How to make a non-recursive Folder Action

Hi everyone,

I have a Folder Action watching a folder to run an Applescript whenever a file is added to it.

The Applescript tells my thumbnail generator app to process the images. This works fine.

The issue is that I'm telling the thumbnail generator to put the processed images into a subfolder of the original folder. When this happens, the Folder Action gets triggered again, and it makes a thumbnail of the thumbnails in yet another subfolder.

This happens only once for some reason, but its still too much.

Is there a way I can set a Folder Action to ignore files added to its subfolders? I need to maintain this directory structure where the thumbnail generator outputs into a child folder.

Here's the script just incase:

Applescript:


on adding folder items to this_folder after receiving added_items
   repeat with eachItem in added_items
       tell application "ThumbsUp" to open eachItem
   end repeat
end adding folder items to

Thanks!

Offline

 

#2 2020-09-24 05:04:14 pm

Marc Anthony
Member
From:: Dallas, TX
Registered: 2006-04-27
Posts: 971

Re: How to make a non-recursive Folder Action

Hi. The expected functionality is that adding contents triggers the mechanism. Use the watched folder to move the dropped items to a processing/processed folder.

Offline

 

#3 2020-09-24 10:06:28 pm

KniazidisR
Member
Registered: 2019-03-03
Posts: 1351

Re: How to make a non-recursive Folder Action

Pugurugu wrote:


Here's the script just incase:

Applescript:


on adding folder items to this_folder after receiving added_items
   repeat with eachItem in added_items
       tell application "ThumbsUp" to open eachItem
   end repeat
end adding folder items to

Thanks!



Simply make your action be ignored for each added item, whose parent folder is not this_folder:

Applescript:


on adding folder items to this_folder after receiving added_items
   repeat with eachItem in added_items
       tell application "Finder" to set itsParent to (container of eachItem) as alias
       if itsParent is this_folder then tell application "ThumbsUp" to open eachItem
   end repeat
end adding folder items to


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Online

 

#4 2020-09-25 06:49:55 am

Pugurugu
Member
Registered: 2020-09-10
Posts: 3

Re: How to make a non-recursive Folder Action

Thanks for this! it seems to be just what I need, but for some reason it's not working. ThumbsUp is still running twice for each image.

Offline

 

#5 2020-09-26 08:05:10 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1351

Re: How to make a non-recursive Folder Action

I installed ThumbsUp to see how it works. As I understand it, the problem is created by the application adding a subfolder to the hot folder. This can be fixed by ignoring the action for any added subfolders:

Applescript:


on adding folder items to this_folder after receiving added_items
   repeat with eachItem in added_items
       tell application "System Events" to set itsKind to kind of eachItem
       if not (itsKind is "Folder") then tell application "ThumbsUp" to open eachItem
   end repeat
end adding folder items to

Last edited by KniazidisR (2020-09-26 08:17:52 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Online

 

#6 2020-09-26 09:35:33 pm

Pugurugu
Member
Registered: 2020-09-10
Posts: 3

Re: How to make a non-recursive Folder Action

KniazidisR wrote:

I installed ThumbsUp to see how it works. As I understand it, the problem is created by the application adding a subfolder to the hot folder. This can be fixed by ignoring the action for any added subfolders:

Applescript:


on adding folder items to this_folder after receiving added_items
   repeat with eachItem in added_items
       tell application "System Events" to set itsKind to kind of eachItem
       if not (itsKind is "Folder") then tell application "ThumbsUp" to open eachItem
   end repeat
end adding folder items to



Perfect! This worked like a charm, thanks so much! big_smile \o/

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)