Hy Folks. I’m trying to convert a droplet (which works fine) in a folderaction.
I’m not good enough in scripting to understand. It seams that it works for the first File I drop but then it won’t work again.
I need different folders changing only pre defined digits of filenames (files/picts) I drop in to the specific folder.
Thanks for support
Daniel
script:
on adding folder items to this_folder after receiving added_items
set prefix to (time of (current date))
tell application "Finder"
repeat with anItem in added_items
--------------------------------------------
-- example replace space 3
set p1 to 3
set k1 to "4"
--don't change
set sel to selection
set neuerDateiname to ""
set alterDateiname to ""
repeat with naechsteDatei in sel
try
set alterDateiname to name of naechsteDatei
end try
set posZaehler to 0
repeat with aChar in every character of alterDateiname
set posZaehler to posZaehler + 1
if posZaehler is equal to p1 then
set neuerDateiname to (neuerDateiname & k1) as string
else
set neuerDateiname to (neuerDateiname & aChar) as string
end if
end repeat
try
set name of naechsteDatei to neuerDateiname
set neuerDateiname to ""
set alterDateiname to ""
end try
end repeat
--------------------------------------------
-- example replace space 1
set p1 to 1
set k1 to "1"
--don't change
set sel to selection
set neuerDateiname to ""
set alterDateiname to ""
repeat with naechsteDatei in sel
try
set alterDateiname to name of naechsteDatei
end try
set posZaehler to 0
repeat with aChar in every character of alterDateiname
set posZaehler to posZaehler + 1
if posZaehler is equal to p1 then
set neuerDateiname to (neuerDateiname & k1) as string
else
set neuerDateiname to (neuerDateiname & aChar) as string
end if
end repeat
try
set name of naechsteDatei to neuerDateiname
set neuerDateiname to ""
set alterDateiname to ""
end try
end repeat
end repeat
end tell
end adding folder items to