seckel
asked on
How do I parse a filename?
Windows 2000 Professional.
I have files like this:
C:\temp
test_001_xxx.txt
test_002_xxx.txt
test_003_xxx.txt
The 001 is the dept code.
I want to reference the dept code in various sections of my dos script.
I have files like this:
C:\temp
test_001_xxx.txt
test_002_xxx.txt
test_003_xxx.txt
The 001 is the dept code.
I want to reference the dept code in various sections of my dos script.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Steve
You are most wise and knowing when it comes to DOS....
You are most wise and knowing when it comes to DOS....
setlocal enabledelayedexpansion
for %%f in (*.txt) do (
set file=%%f
set dept=!file:~5,3!
echo !dept!
)
pause