set search_string to "P591.02"
set fol_ to (choose folder)
tell application "Finder"
set files_ to (files of fol_ whose name begins with search_string) as alias list
end tell
repeat with file_ in files_ -- process each file
-- do something to file_
end repeat
I have just the opposite situation. I have a folder with over 300 items that start with different words but all have the same ending “Name-Old.ext” how would the wildcard selection work to identify the first file, change the ending to “Name-New” but leave the beginning of the file name unchanged?
Such:
change, XXXXname-old.ext
to, XXXXname-new
where XXXX could be any number of integers, XXXXXX, XX, XXX, XXXXXXXX, etc.
I can get to the folder, and select the first file;
––if file (old-name.ext exists) select first file
but have been stumped in how to change the file name then select the next, and so on.