Batch Scipt to Add the File Name to File

June 15, 2009 at 14:10:31
Specs: Windows XP
I have a few hundred files, each with a different name (e.g. 012345.htm, 987654.htm, etc...). Each file has to have the file name in it. Is there a batch script using the filename as a variable that will work? I can't figure it out. Thanks.

See More: Batch Scipt to Add the File Name to File

Report •


#1
June 15, 2009 at 14:58:30
Do you mean you want to append the file name at the end of each file? This should do it:

for %%f in (*) do (
echo.>>%%f
echo File name: %%f>>%%f
)

If you want the file name at the start of each file, it's slightly more complicated and slower to execute.


Report •

#2
June 15, 2009 at 15:15:23
That's just what I needed. Thank you.

Report •

Related Solutions


Ask Question