Search File Name and Copy found documents to another folder

I have what I think is a simple script but I sure can’t figure it out.

Can somebody get me started in the right direction please

Step One:
I have a folder w/subfolders. Within these folders are ~81,000 PDF files.

Folder Layout:
{Root}

{YYYY}{MM}
{Date}_{Account Number}.pdf

I’m looking to search the Root of the folder for all documents with a certain {Account_Number}

Example:
Search for 88954 and it returns all the documents with that in the filename.

Step Two(optional)
I have a list of account numbers within excel. It would be great if I could use this list and automate the input. It’s only about 400 accounts but it would help if it could be automated.

Thanks again for you help. I’ve been getting the hang of Apple Script, as it’s been super helpful.

If tge folder is on a regular place you can use spotlight to get the files through the shell like this.

every paragraph of findFiles("88954", "/path/to/root/folder")

on findFiles(searchName, directoryToSearchIn)
	do shell script "mdfind -onlyin " & quoted form of directoryToSearchIn & " -name " & quoted form of searchName
end findFiles

If you want to explicit it to files ending with “.pdf” you could use the line

do shell script "mdfind -onlyin " & quoted form of directoryToSearchIn & " -name " & quoted form of searchName & " | grep '.pdf$'"

Whoops just reread my post and forgot something.

Once I find the matching files I need to copy them to another folder then move on to the next one down the list.

set targetFolder to "/Users/john/Desktop/"
set theFiles to findFiles("88954", "/path/to/root/folder")
repeat with theFilePath in theFiles
do shell script "mv " & quoted form of theFilePath & " " & quoted form of targetFolder
end

on findFiles(searchName, directoryToSearchIn)
try
  return  every paragraph of (do shell script "mdfind -onlyin " & quoted form of directoryToSearchIn & " -name " & quoted form of searchName & " | grep '.pdf$'")
on error
--probably grep didn't found anything
return {}
end
end findFiles