Wednesday, November 20, 2019

#1 2019-10-20 04:25:05 am

Jeremy photo
Member
Registered: 2019-10-19
Posts: 1

Select automatically a tagged file in a folder

Hi there,

I would love some help with my Applescript included in an automator workflow.

After choosing a folder in a prompt, I would like the script to automatically look for the only color tagged folder in the chosen folder and copy the name and create a variable in automator.


Is that possible to do with applescript?

Thanks

Offline

 

#2 2019-10-23 01:00:20 pm

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

Re: Select automatically a tagged file in a folder

Hi, Jeremy Photo.
Assuming that you have attached to your folders some colour tags OR nothing, you can use the following simple handler as Run AppleScript action. The name will be remembered by Automator in the variable input:

Applescript:


on run {input, parameters}
   set aFolder to choose folder
   
   tell application "Finder"
       set theFolders to folders of aFolder whose label index is not 0
       set foldersPaths to {}
       repeat with anItem in theFolders
           set end of foldersPaths to name of anItem
       end repeat
   end tell
   
   set input to foldersPaths
   return input
end run

Remember: the input will be a list, and not single value.

I think, it is better get Posix paths of folders with colour tags, instead of names:

Applescript:


on run {input, parameters}
   set aFolder to choose folder
   
   tell application "Finder"
       set theFolders to (folders of aFolder whose label index is not 0) as alias list
       set foldersNames to {}
       repeat with anItem in theFolders
           set end of foldersNames to POSIX path of anItem
       end repeat
   end tell
   
   set input to foldersNames
   return input
end run

Last edited by KniazidisR (2019-10-23 01:12:44 pm)


Model: MacBook Pro
macOS Mojave -- version 10.14.4
Safari -- version 12.1
Firefox -- version 70.0

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)