Tag folder based on its contents directly

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Tag folder based on its contents directly Mon Feb 25, 2019 8:55 am • by kristofk
In my folder structure, in the Documents folder, I have Xcode projects. An Xcode project is a folder with a bunch of files in it including a .xcodeproj file.

These projects can be at any depth anywhere in the folder structure. So in order to check if a folder is a project I have to check if it contains an Xcode Project file. If the folder is a project then I want to add the "Code" tag to it.

I tried the following rules but the problem is that this marks the topmost folder as "code".
https://ibb.co/gZWsZmg
https://ibb.co/LgHnSdy

How can I mark a folder that directly contains an Xcode project file?
kristofk
 
Posts: 2
Joined: Mon Feb 25, 2019 8:43 am

Unfortunately, using the "any of its sub-files" target includes things further down in the hierarchy. One solution would be to match the xcodeproj file itself, but use the ability to re-target a file in AppleScript as described here: viewtopic.php?p=1545#p1545
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Tag folder based on its contents directly Mon Feb 25, 2019 10:06 am • by kristofk
Mr_Noodle wrote:Unfortunately, using the "any of its sub-files" target includes things further down in the hierarchy. One solution would be to match the xcodeproj file itself, but use the ability to re-target a file in AppleScript as described here: viewtopic.php?p=1545#p1545


This works perfectly.

Code: Select all
tell application "Finder"
   set posix_parent_dir to POSIX path of (container of (item theFile) as text)
   
end tell
return {hazelSwitchFile:posix_parent_dir}
kristofk
 
Posts: 2
Joined: Mon Feb 25, 2019 8:43 am


Return to Support