I want to search a particular folder for a file that contains a certain string within its name. And then delete that file. For example. Search a folder on my icloud drive and if any filename contains “_Data”, then delete that file.
Ex Folder: “/Users/Joe/Library/Mobile Documents/com~apple~CloudDocs/Stuff/”
Ex Files:
Test.jpeg
build12.xlxs
G33762.doc
homed.text
56_Data.numbers
So I want to delete the file “56_Data.numbers” because it contains “_Data”
This is what I have. All my efforts to insert code to make it work have failed.
Any suggestions? Thanks
property hFolder : “/Users/Joe/Library/Mobile Documents/com~apple~CloudDocs/Stuff/”
set newFileList to list folder hFolder without invisibles
repeat with m from 1 to number of items in newFileList
if (m as text) & "_Data.numbers" is in newFileList then
else
end if
end repeat