Simply remove the extra space from your source ;)
for /F "tokens=*" %%A in (C:\test\Index.txt) do (
I also used
echo( to guard against lines that become empty when you strip the first character.
ECHO without anything following results in
ECHO is off. message in your output.
Your simplistic script works fine in many cases. But it will have problems if your input contains
! character, or if you need to preserve blank lines. There are solutions for those issues, but the code becomes more complicated, and slower.
I use a hybrid JScript/batch utility called REPL.BAT whenever I want to modify contents of a file. It performs a regex search and replace on stdin and writes the result to stdout.
Assuming REPL.BAT is in your current directory, or better yet, somewhere within you PATH, then your script could be replaced with the following one liner that is both faster and more reliable:
type "C:\test\Index.txt"|repl "^." "" >"C:\test\Index1.txt"