I have a text file that contains a list of filenames, minus the extension, that I need to create. I want to run a quick batch file command or VBS script that will iterate through the list and then create a file based on the name.
The text file looks something like this:
PRXI0000466
PRXI0000564
PRXI0000636
PRXI0000681
PRXI0001092
So I want to loop through each line, then do an "echo . > %file%.txt
" (assuming %file%
contains the line from the text file).
Can anyone show me a quick way to do this?
Best Solution
Well, this is a one-liner in cmd:
for /f
loops line-wise hrough a text file, and doing tokenizing on the way as well. Luckily for you there are no spaces in your lines, otherwise this would have called for something like"delims="
on there as well.This would put a single line containing a dot follows by a space in each new file. If you just want a blank line you'd have to use
echo.>%i.txt
. If you just want to create each file (UNIX geeks might just usetouch
(1)) you can usecopy NUL %i.txt
. If you want to use this in a batch file (and not directly from the command line) then you'd have to use%%i
instead of%i
.I think you really want to create empty files, so the following should do the trick: