Q: can i convert the choose option in applescript in Auto folder action setup
hi,
I h've an applescript which is work to sorting a folder image and arrange it to folder wise according to its name uniqueness.
In this script have choose folder option but i want to convert the option in automatically like Folder action setup. like
on adding folder items to this_folder after receiving these_items
Here is my script
set d to choose folder
_main({d})
on _main(argv)
script o
property ff : {} -- list of aliases
property gg : {} -- list of aliases to be moved per prefix
property nn : {} -- list of file names
property mm : {} -- list of prefixes
property mm1 : {} -- list of distinct prefixes
repeat with d in argv -- per source directory
set d to d's contents
-- retrieve list of aliases and names for document files
tell application "Finder"
tell item d's document files to set {ff, nn} to {it as alias list, name}
end tell
try
set {astid0, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {"_"}}
repeat with i from 1 to count my nn
set {n, m} to {my nn's item i, ""}
if (count n's text items) > 1 then set m to "" & n's text items 1 thru -2
set my mm's end to m
if m ≠ "" and m is not in my mm1 then set my mm1's end to m
end repeat
set AppleScript's text item delimiters to astid0
on error errs number errn
set AppleScript's text item delimiters to astid0
error errs number errn
end try
repeat with m in my mm1 -- per distinct prefix
set m to m's contents
-- prepare destination for this prefix
try
set dst to (d as string) & m & ":" as alias
on error number -43 -- dst not present
tell application "Finder" to set dst to (make new folder at d with properties {name:m}) as alias
end try
repeat with i from 1 to count my mm
if my mm's item i = m then set my gg's end to my ff's item i
end repeat
if gg ≠ {} then tell application "Finder" to move gg to dst with replacing
set gg to {}
end repeat
end repeat
end script
tell o to run
end _main
so if support to convert this script to folder action script so please support to do it.
Thanks
Rakesh
Mac Pro, Mac OS X (10.5.5)
Posted on Jun 8, 2016 5:41 AM