Hello!
I have a need to parse a set of filenames into seperate pieces for additional processing. The files will be of varing length, but with the same prefix and file extension. I need to strip the prefix and file extension off and the do another task on the part of the filename that is remaining and of course loop through a list of files.
In this example there are 3 files:
PrefixTable1.dat
PrefixDatabase.dat
PrefixArchive.dat
What I need assitance with is to strip Prefix and .dat from the 3 files, so that what is stored in a variable or variables is Table1, Database, and Archive.
Any help?
Thanks,
Doug
Parsing a filename into seperate pieces
Moderator: DosItHelp
dlrosencrans,
Let's say the files are in c:\FullPath\:
DosItHelp?
Let's say the files are in c:\FullPath\:
Code: Select all
Setlocal Enabledelayedexpansion
for %%A in ("c:\FullPath\Prefix*.dat") do (
set "FileNameWithoutExtension=%%~nA"
set "SubString=!FileNameWithoutExtension:*Prefix=!"
echo.Do somthing with !SubString!
)
DosItHelp?