Computing.Net > Forums > Programming > Batch Scipt to Add the File Name to File

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch Scipt to Add the File Name to File

Reply to Message Icon

Name: huckab
Date: June 15, 2009 at 14:10:31 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: klint
Date: June 15, 2009 at 14:58:30 Pacific
Reply:

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.


0

Response Number 2
Name: huckab
Date: June 15, 2009 at 15:15:23 Pacific
Reply:

That's just what I needed. Thank you.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


How to compare 2 file dat... Moving Files based on nam...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch Scipt to Add the File Name to File

Batch to add the column in a txt file www.computing.net/answers/programming/batch-to-add-the-column-in-a-txt-file/19625.html

Add new file extensions to registry www.computing.net/answers/programming/add-new-file-extensions-to-registry/9106.html

Batch to add leading zero to date www.computing.net/answers/programming/batch-to-add-leading-zero-to-date/19782.html