I have a batch file with an external configuration file. Say I needed to delete files specified in a configuration file as a delimited list on one line. The files could look like this:
[config.cfg]
*.pdb;*.config
[batch.bat]
...
for /f "tokens=* delims=;" %%b in (%DATA_10%) do (
CALL DEL "%%b%"
)
...
The batch code should iterate through the list of files and delete them.
If I have another external file assigned to %DATA_10% variable which contains the list of files to delete on开发者_如何转开发e per line then it works perfect. However what I need is the files to be extracted from config.cfg as you see above (all on one line) otherwise I would have too many config files required in my batch.
Any idea for a solution?
If config.cfg only contains one line with your data, you could use
set /p DATA_10= < config.cfg
But your FOR /F loop expands only once per line, so it can't work this way. You could change it to
FOR %%a in (%DATA_10%) do (call del "%%b")
But you should be sure not to use * or ?, because they are interpreted as wildcards in a "normal" for-loop
精彩评论