Using Apple script to delete selected items if they contain a specific string
0
votes
1
answer
75
views
I am almost totally ignorant in scripting, although I am a bit of a geek and several times I managed to edit and adapt code i found on the web, to perform simple but useful tasks that we use in mine and my team's work.
I am trying to find a solution to something that in my mind should be very easy, but obviously I lack fundamental knowledge to understand.
Given an amount of items selected in Finder, I'd like to use applescript to move to the trash any file of that selection that contains a text string in the file or folder name.
So far I have got this which will correctly move to the trash every item that I have got selected in Finder
tell application "Finder"
set selectItems to selection
delete (every item of selectItems)
end tell
If I try something like this though, it will return an error
tell application "Finder"
set selectItems to selection
delete (every item of selectItems whose name contains "String")
end tell
Would anyone be so generous to give me a solution to this problem, while also filling me in on what foundational knowledge I am missing in relation to it?
Many thanks in advance!!
Asked by Rex23
(11 rep)
Mar 24, 2025, 06:46 PM
Last activity: Mar 25, 2025, 10:52 AM
Last activity: Mar 25, 2025, 10:52 AM