I want to avoid the execution of shell script (i.e. mv command) if the file already exists in the destination folder. I am unable to do it. Please correct my mistake in the script below. The problem lies in
set dfolder to alias "7:V2:4:"
set destination to quoted form of POSIX path of dfolder
set ifolder to alias "8:Firefox Downloads:DownThemAll:"
set thepath to quoted form of (POSIX path of ifolder)
tell application "Finder"
set dtafilenames to name of every file in dfolder
set filenames to every file in folder ifolder
repeat with afilename in filenames
afilename
set y to count of (name of afilename as text)
if name of afilename begins with "24" and (name of afilename ends with ".rm" or name of afilename ends with ".srt") and (y is 11) then
set x to name of afilename
set source to thepath & x
if (not (exists x in dtafilenames)) then
do shell script "mv " & source & space & destination
end if
end if
end repeat
end tell