Find a file who's name contains a specific word & move it

Why do I always feel like I know NOTHING about Applescript!!!:smiley:
Anyway, here is my script. I’m trying to locate a file with a specific word in it’s name & move it to another folder.

on run set sourceDirectory to (path to documents folder from user domain as Unicode text) set destinationDirectory to ((path to documents folder from user domain as Unicode text) & "Destination") set folderList to list folder sourceDirectory repeat with fileFind in folderList if fileFind contains "project" then move (fileFind as alias) to destinationDirectory end if end try end run
It says the file does not exist! But it states the exact (full) name of the file in the error & I can see the file is in there.

Hi,

only the Finder and System Events know about the existence of a file.
Instead of a repeat loop you can filter for the string


set sourceDirectory to (path to documents folder as text)
set destinationDirectory to ((path to documents folder as text) & "Destination:")
tell application "Finder" to move (get files of folder sourceDirectory whose name contains "project") to folder destinationDirectory


Thanks StefanK. I will try it tonight.

Thanks! That worked.
I had a Tell Finder statement in there, but for some reason I took it out.