Hi:
Here I’ve a simple script to find file names with same name and group in new folder (folder name is same as file name):
My problems is that I used “on adding folder” and attached with folder but it does nothing.
Thank you!
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
on adding folder items to this_folder after receiving these_items
tell application "Finder"
tell item these_items 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
set m to m's contents
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 adding folder items to