hi,
Thanks for support.
i have tried it but it's not working properly.
when i use this script to folder action utility and upload on a folder action it not work.
my script is here please check and revert me your valuable support.
on adding folder items to this_folder after receiving these_items
repeat with d in these_items
tell application "System Events"
set p to properties of d
if type identifier of p is "public.folder" then
_main({d})
end if
end tell
end repeat
on_main(argv)
(*
list argv : list of source directories
*)
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
-- retrieve prefixes from file names
(* E.g.
name = AAA_BBB_CCC_DDD.tif
prefix = AAA_BBB_CCC
*)
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
-- distribute files per prefix
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
-- collect sources for this prefix
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
-- move collected sources to destination
if gg ≠ {} then tell application "Finder" to move gg to dst with replacing
-- reset this collection
set gg to {}
end repeat
end repeat
end script
tell o to run
end_main
end adding folder items to
This is the script which i use on Folder action utility.
Thanks
Rakesh