Directory Path Match Certain Pattern

January 26, 2011 at 23:29:48
Specs: Windows XP
Hi All

I am very new to Dos Script, however I have a task on hand which I believe will be most efficient to execute in Dos Scipt(.BAT).

I will run this BAT file in Window XP Professional

Currently I have a Drive let's say B: Drive which consists of 30 folders and 100,000+ sub folders(not files)

Within the drive there are more than ten thousand job folder and each with a job number

I need to print out a list of all folders that consist of a job number

The job number pattern (imagine the job number is A1234567 with the first char always an alphabet and the follow by 6 - 7 numeric character then a space and the job name

e.g B:/Lv1/Lv2/A1234567 xxxxx/Lv4/Lv5/xxx.xls

Unfortunately this job number maybe in different level

e.g B:/Lv1/Lv2/A1234567 xxxxx/Lv4/Lv5/xxx.xls

e.g B:/Lv1/B5678214 xxxxx/Lv3/Lv4/xxx.xls

e.g B:/Lv1/Lv2/Lv3/Lv4/Z0425673 xxxxx/Lv5/Lv6/xxx.doc

Lets say if we start from the top and once the sciprt find the job number, it wont continue to drill down to another level from that folder.

So the outcome will be like this

e.g B:/Lv1/Lv2/A1234567 xxxxx

e.g B:/Lv1/B5678214 xxxxx

e.g B:/Lv1/Lv2/Lv3/Lv4/Z0425673 xxxxx

I know this might be a very easy and simple question but I really appreciate if someone can point me to the right direction

Thanks in advance

See More: Directory Path Match Certain Pattern

Report •

January 27, 2011 at 06:56:04
You need something that is constant and unique. You could loop through all letters in the alphabet looking for directories that start with the letter but every directory will meet that criteria.

Can you come up with a letter combination that is the same in all of the "Jobs"?

Like all jobs start with JOB: then B5678214, then we could search on the word JOB. But to say I am looking for something that starts with a letter any letter can you help, is impossible.

If you had a list of the JOB numbers in a text file then we could go through the list and look for folders that have that number or if all jobs even started with a fixed letter like A then you could do a...

dir A* /AD /S

Which would return all directories that started with the letter A. Think of something that is unique and constant.

Report •

February 1, 2011 at 17:49:11
Thanks for the tips
Although the folder name itself doesnt have a constant name, but the folder below one level does, so I think If I search all folder that has this name should work

Report •

Related Solutions

Ask Question