Basically, I have 50 to 100 text files dumped into a single directory. The first line of each text file has a customer number. Example: 150, 750, 2151, etc.
I am wanting to make a button or script where it searches each file for a regex like ^150$ and when it finds the customer number, it renames the file with the customer number first in the name like this:
Search for 150 > rename all matching files to 150_oldname.txt
Search for 750 > rename all matching files to 750_oldname.txt
I already have a button set to go to the folder automatically. I have searches set up to find the files, but if can autumate this into one button it would be great. What would be a good way to do this?
Could you make a few example files and zip them up so we can make sure what we do works with what you're expecting?
Sure, thanks Leo. I have attached a sample folder with order files. (I have manually renamed the files to be correct) You'll notice the first line of each file matches the first part of the file name. Pretty simple stuff.
If you have any questions, please let me know.
Thanksdump directory.zip (1.2 KB)
I meant to add, there is only 5 customers who this applies to. So I don’t need anything complicated.
Here's a rename script which does that:
Prefix First Line.orp (675 Bytes)
Import it into the Rename dialog via this menu item:
Leo, This is perfect! Thank you!