Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Script not working 'check to duplicated items?

Here is my script with many help from people here already I have tried combining a script and I can't see where its not working, it runs just doesn't function as it should.


it moves items of a folder to another relevant folder. if the item exists I should get a prompt saying so and then the option to put it into another folder or overwrite.

Any suggestions? please


set fileMatrix to

{folderName:"BHS", prefixes:{"BH", "SM", "AL"}}, ¬

{folderName:"Bu", prefixes:{"BU"}}, ¬

{folderName:"Da", prefixes:{"ES"}}, ¬

{folderName:"Di", prefixes:{"DV"}}, ¬

{folderName:"Do", prefixes:{"DJ", "RA"}}, ¬

{folderName:"In", prefixes:{"GT", "CC"}}, ¬

{folderName:"Fr", prefixes:{"FR"}}, ¬

{folderName:"No", prefixes:{"NN"}}, ¬

{folderName:"Ma", prefixes:{"MA", "MF", "FI", "MC", "MH", "MB"}}, ¬

{folderName:"Pr", prefixes:{"PR"}}, ¬

{folderName:"To", prefixes:{"TM15", "TM11", "TM17"}}, ¬

{folderName:"Wa", prefixes:{"WA"}}, ¬

{folderName:"Se", prefixes:{"SE"}}}



tell application "Finder"

set theHotFolder to folder "Hal 9000:Users:matthew:Pictures:HotFolder2Do"

set foldericon to folder "Hal 9000:Users:matthew:Pictures:Icons:Rejected Folder Done"


if not (exists folder "Hal 9000:Users:matthew:Desktop:Rejected Folder Done") then

set theLastFolder to duplicatefoldericontodesktop

else

set theLastFolder to folder "Hal 9000:Users:matthew:Desktop:Rejected Folder Done"

end if


repeat with matrixItem in fileMatrix-- look for folder

set destinationFolder to (folders of desktop whose name starts with folderName of matrixItem)

if destinationFolder is not {} then -- found one

set destinationFolder to first item of destinationFolder-- only one destination

set theFolderName to name of destinationFolder


repeat with aPrefix in prefixes of matrixItem-- look for files

set theFiles to (files of theHotFolder whose name starts with aPrefix) as alias list


if theFiles is not {} then repeat with aFile in theFiles -- move files


try


moveaFiletodestinationFolder


activate

display dialog "File “" & (name of aFile) & "” already exists in folder “" & theFolderName & "”. Do you want to replace it?" buttons {"Don't replace", "Replace"} default button 2 with icon 1

if button returned of result is "Stop" then

if (counttheLastFolder) is 0 then deletetheLastFolder

return

else if button returned of result is "Replace" then


moveaFiletodestinationFolder with replacing

else -- "Don't replace"


moveaFiletotheLastFolder with replacing

end if


end try

end repeat

end repeat

end if

end repeat

if (counttheLastFolder) is 0 then deletetheLastFolder

end tell

iMac, Mac OS X (10.6.8)

Posted on Dec 10, 2012 4:12 AM

Reply
Question marked as Best reply

Posted on Dec 10, 2012 6:52 AM

Missed one important bit!


"on error"

All working now!


try


moveaFiletodestinationFolder

on error


activate

1 reply

Script not working 'check to duplicated items?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.