Can I query a windows folder to select a specific list of files in search results?

I have 26,000 pictures in one folder called "Images".  Each picture contains each product's item code in it.  I'd like to query the Windows folder "Images" to give results of a pre-determined list of item codes - say that are in a referring table.  Is this possible?  Of course the query would have to use a wild-card search...
Item Code = 081124555435
Picture Name = 081124555435xactual.jpg

So I'll need to pull batches of around a 100 pictures for many different product types many times - all with different item codes.

Of course I can do one by one with a copy paste, but I'm almost 50 now and I feel I may not have that much time left on the planet!  :D

Update: I actually have the exact name of the file I want for each item.  
Here's a sample list of those:
itsquadSystems AdminAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITEnd-user supportCommented:
Sorry. I think you wanted to search with Windows, and not a cmd/batch solution, right?
ITSysTechSenior Systems AdministratorCommented:
You would put this in the search bar with comma separation (in advanced search mode).  This works for XP. What OS are you using?

ITSysTechSenior Systems AdministratorCommented:
For Windows 10 or 7 your could use this.  683274011097xactual.jpg OR 761294017814xactual.jpg OR 761294015193xactual.jpg

Also, 081124555435 OR 081124555443 OR 081124553434
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

NVITEnd-user supportCommented:
> I'd like to query the Windows folder "Images" to give results of a pre-determined list of item codes - say that are in a referring table

Can you elaborate?
itsquadSystems AdminAuthor Commented:
So thanks all... still stuck
The OR works, but the criteria I paste in gets truncated to the 255 limit.  
My first batch has 1,791 characters.  
Not sure if there's an outside program that would handle that or if there's
a setting in OS to open that up??

Thanks, Kevin
Joe WinogradDeveloperCommented:
Hi Kevin,
I don't understand your requirements well. A few questions trying to clarify before it's possible to help you:

(1) What exactly do you mean by a "referring table"? An Excel spreadsheet? A table in Word? A plain text file with a line for each file name?

(2) Is the file name in the "referring table" fully qualified or is the path specified elsewhere? If the latter, where is the path specified?

(3) What exactly do you mean by "pull batches"? In other words, after querying/selecting around 100 pictures (that are in the "referring table"), what do you want to do with them?

Regards, Joe

UPDATE: I just noticed NVIT's excellent "Can you elaborate?" question. That's a great summary of what I'm looking for. :)
itsquadSystems AdminAuthor Commented:
Hi Joe, thanks for the reply!  Sorry for my semantics, I didn't mean it to read as a "read between the lines" kind of deal :D

Basically the bottom line question is...

Can I do a multi-file search in Windows 7 that's over 255 characters long?

I can generate a string of text that is formatted for multi-file search.  Example "1231254.jpg" OR "5466646.jpg" OR "456...."  
My problem is that the string I paste into the Windows 7 Search Box is way beyond 255 characters so no results happen.
When I put part of the string in that is under 255 characters, it works.

I was curious if anyone knew of maybe a software program that would be able to accommodate the over 255 characters limit or if there was a way to connect Windows 7 Search programming to perhaps an access table, xls, xml, vb, or word table or whatever data source to limit the results to just the file names desired.  

Hope that wasn't even more confusing, if it was... I'll be devastated!  :D

Thanks again, Kevin
NVITEnd-user supportCommented:
> I'd like to query the Windows folder "Images" to give results of a pre-determined list of item codes - say that are in a referring table

I think what you want is to be able to pass each line of your "batch", i.e. search for, matching files in a folder. Is that correct?

If so, you can make a text file of the batch search terms. One term per line.

Then, pass each line to the FIND or FINDSTR command, which returns the matching file names.

But, as Joe asked: What will you do with the results? Do you wanna process those further?

Or, must the results exist in the Windows Search window?
itsquadSystems AdminAuthor Commented:
Hi NVIT, as far as I know, yes that is correct.
I will then need to copy those images to a different folder, so if the results did show in the Windows Search window, that'd be handy.
I don't know what "pass" really means and I don't know how to do a batch file.
Does this sound like a novice project for me to learn or how would you suggest I go about getting the batch file put together?

Thanks again, Kevin
NVITEnd-user supportCommented:
We can help make a batch file for you.

In your sample list above:

Open in new window that list what you're searching for, i.e. where you enter what to search for?
Joe WinogradDeveloperCommented:
Hi Kevin,
Much better — I think I understand now. :)

> I can generate a string of text that is formatted for multi-file search.

As I mentioned in my previous post, you could create a plain text file with a line for each file name. I would take the idea further by fully qualifying the source file name, e.g.,


> I will then need to copy those images to a different folder

One idea is to prefix each line with copy and suffix each line with the fully qualified destination file name, such as:

copy D:\SourceFolder\683274011097xactual.jpg E:\DestinationFolder\683274011097xactual.jpg
copy D:\SourceFolder\761294017814xactual.jpg E:\DestinationFolder\683274011097xactual.jpg

This forms a proper copy command. Simply put all of those lines in a plain text file with the .BAT file type and run it. That should do it. Regards, Joe

UPDATE: Sorry, Kevin, I just noticed this comment in your last post: "I don't know how to do a batch file." A batch file is simply a plain text file that you can create with any text editor. You place commands in it, such as the copy command mentioned above. When you save the file with your favorite text editor, do a Save As with a file extension of .BAT (such as saving to a file called CopyMyFiles.bat). Then you simply double-click on the .BAT file in Windows/File Explorer (or whatever file manager you use).

If you want to get adventurous, you could learn a more robust scripting language than batch files, such as AutoHotkey or PowerShell. Here are are a couple of Experts Exchange articles to get you started down that path, if it interests you:
The Absolute Beginner's Guide to Powershell
AutoHotkey - Getting Started

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NVITEnd-user supportCommented:
And if you need a good, popular, free text editor, that's way better than the built-in Notepad, see Notepad++
Joe WinogradDeveloperCommented:
Great suggestion by NVIT! Notepad++ is an excellent (free!) text editor that is far superior to the built-in Notepad. One of its features that is really helpful for this project is Regular Expression (RegEx) support in its Search-Replace dialog, which Notepad does not have. For example, to add copy (with a space at the end) to the beginning of every line in the file, click the Search menu, then Replace, and fill in the dialog like this:

npp prefix
Then click the Replace All button. Although it's not obvious in the screenshot, there's a space after copy. So that would change all lines like this:


to this:

copy D:\SourceFolder\683274011097xactual.jpg
copy D:\SourceFolder\761294017814xactual.jpg

Although I showed the full file name in my previous post, a better way is simply to use *.* in the destination file name. Then all you have to do in Notepad++ is use the RegEx Search-Replace feature again, but this time to add the destination to the end of every line, like this:

npp suffix
Then click the Replace All button. Although it's not obvious in the screenshot, there's a space before E:\DestinationFolder\.

So that would change all lines like this:

copy D:\SourceFolder\683274011097xactual.jpg
copy D:\SourceFolder\761294017814xactual.jpg

to this:

copy D:\SourceFolder\683274011097xactual.jpg E:\DestinationFolder\*.*
copy D:\SourceFolder\761294017814xactual.jpg E:\DestinationFolder\*.*

Now your batch file is good-to-go! Regards, Joe
NVITEnd-user supportCommented:
That's a great Notepad++ replacement example by Joe.

To reduce Joe's replace steps a bit...

Assuming your text lines look like:

Open in new window

Find what: ^(.+)$
Replace with: ^copy "D:\\SourceFolder\\\1" "E:\\DestinationFolder"$

I'm on mobile so can't confirm but I think you need the ^ and $ in the Replace field. Try it and see.
Joe WinogradDeveloperCommented:
NVIT makes three excellent points: (1) Even the *.* is not required, i.e., the copy command works fine with just the destination folder name. (2) A single RegEx replace can append at both the beginning and end of the line. His RegEx Find what is right, but the Replace with should not have the ^ and $. (3) It's a good idea to surround the source and destination with quote marks, in case those fields have spaces in them (the quote marks are not needed if there are no spaces, but are necessary if there are any spaces at all in the names, so it's good practice to include them).

Great stuff from NVIT! And now it's time for bed in my neck of the woods. The Hawaiian time zone will pick it up from here, I'm sure. :)  Regards, Joe
itsquadSystems AdminAuthor Commented:
Joe & NVIT - You guys ROCK!!  Thanks a bunch!!  I remembered a program that I had used years ago called "Bulk Rename Utility".
They have an import function called "Rename Pairs" that you create as a .txt file in note pad.  Basically the txt file has
"Original File Name | New File Name".  With that I was able to rename the 2,500 files I wanted from the 26,000 files.  In the rename, I put a unique handle so I could grab them all from Windows search.  Then (even though I was getting truncated) I was able to old school/caveman them in from Windows search in about 30 minutes via copy paste. :D    Thanks again guys!  I look forward to referring back to the notes here on this post for future situations and hopefully I'll have more time to wrap my head around your guys' better & faster solution and not have to caveman it up!  :D
NVITEnd-user supportCommented:
Hi Kevin...

I'm glad things turned out well for you. Having Joe the expert always helps, too...

"Bulk Rename Utility" is a great tool, also. And FREE! Your rename method is definitely caveman 🤣.

IIRC, it also has a regex feature that works similar to NPP. So, using BRU would definitely be faster. A very nice feature is the 'preview' option, which let's you verify the consequences first.
Joe WinogradDeveloperCommented:
First, Kevin, thanks for the kind words — much appreciated! And thanks for letting us know how you solved the problem — feedback like that is very valuable. Rather than "caveman", I'd go with the kinder, gentler "old school". :)

Yes, Bulk Rename Utility is a good one...especially for free! Another good one in that space is Flash Renamer, but it's not free (although it is reasonably priced and offers a free trial).

My thanks, also, to NVIT for the compliments, which I'll send right back at you. Your batch file and RegEx skills are light years ahead of mine and I always learn a lot from your posts. It's a pleasure to collaborate with you on solutions here at Experts Exchange — such as this one.

Regards, Joe
Joe WinogradDeveloperCommented:
Once we nailed down the exact requirements, we got to an answer. Splitting points evenly between the two experts who arrived at the batch file/scripting solution along with recommendations on how to build the source code in a text editor.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.