Reputation: 13
txt files from a list i have,i can create the files no problem but stuck when i try to add sequencial numbering(1,2,3...)to the start of the files.
Here what i have:
for /f "delims=" %%i in (list.txt) do echo %%i > %%i.txt
here some of the names on the list for example:
Crabs Versus Skeletons
The Quest For Braccus Rex
The Teleporter Pyramids
The Wishing Brother
A Voice in the Wilderness
And about 100 more
It creates the .txt files from the list no problems,but what i want is:
1 Crabs Versus Skeletons
2 The Quest For Braccus Rex
3 The Teleporter Pyramids
4 The Wishing Brother
5 A Voice in the Wilderness
6..and so on...
with the sequential numbers at the start of the name,any help would be appreciated.
Upvotes: 0
Views: 26
Reputation: 80073
for /f "tokens=1*delims=[]" %%a in ('find /v /n "" list.txt') do >"%%a %%b.txt" echo(%%a %%b
Omit the "%%a " from whichever (filename or text-content) if required
Upvotes: 0
Reputation: 9545
Another way :
@echo off
setlocal enabledelayedexpansion
set "$c="
for /f "delims=" %%i in (list.txt) do (
set /a $c+=1
echo !$c! %%i > %%i.txt
)
Upvotes: 1