Solved Comparing several files using specific parts of their names

June 22, 2012 at 10:46:08
Specs: Windows XP

Is it possible to compare two or more files using not their whole names, but parts of their names?
Like this: Let's say I am deploying a .sql file with the name a_b_DEV.sql and it creates a log file that is called a_b_DEV_log.txt.
Now, I have several of those .sql files, such as: a_b_OFF.sql, ..._TST.sql, ..._ABD.sql, and they all create their own log files.But the beginning of their names (a_b_) stay the same.
What I am trying to do is have ONE .vbs file that emails the user with the right log file attached. Is it possible to achieve that. Sorry, it is in vbs, but my main script is in batch. I had to write the emailer in vbs. If I accomplish it, it would be a lot more dynamic and organized, compared now, where I have separate emailer .vbs files for each one of those OFF, TST, ABDs.

Any ideas?


See More: Comparing several files using specific parts of their names

Report •

June 22, 2012 at 11:47:30
✔ Best Answer
Use substrings to read the part of the filename that you need"

C:\test>set f=a_b_DEV.sql

C:\test>echo %f:~4,3%



Report •

June 22, 2012 at 12:13:25
Thanks for a quick response, Tony.
I don't think if it will work in my case. Because, the number of letters in the names might change and i would have to put in the new numbers manually every time, you know what i mean?
Is it possible to read the name in reverse? Start from the end and just grab the last 6-7 digits?

Report •

June 22, 2012 at 12:23:23


Will grab the last 7 characters.


Report •
Related Solutions

Ask Question