Apple script in Automator - to remove same name files with different extensions
Hi there,
I do have a folder with more than 6000 files which are somehow listed like this:
file1.jpg
file1.pdf
file2.jpg
file3.jpg
file4.jpg
file4.pdf
...
I would like to run a script to identify and delete JPG files that DO HAVE an associated PDF file. In the exemple above, it would only delete file1.jpg and file4.jpg because file1.pdf and file4.pdf exist.
I have tried to accommodate scripts I found out there to make this work as I am no expert. At this point, I am trying to run a Apple script in Automator that looks like that:
set ff to choose folder
tell application "System Events"
set everyJpg to files of ff whose name extension = "jpg"
repeat with thisJpg in my everyJpg
set thisPdf to my getBaseName(thisJpg) & ".pdf"
if (exists file thisPdf of ff) then
delete thisJpg
end if
end repeat
end tell
However, I get an error message like :
"The action "Run AppleScript" encountered an error: Can't make file "Mackintosh HD: Users: Zalmati:MyFolder:file2.jpg" of application "System Events" into the expected type"
From what I can tell, the script looks plain and simple but I don't know how to troubleshoot this.
Is there something easy I am missing?
Thanks,