Computing.Net > Forums > Programming > Bat script overwrite text 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.

Bat script overwrite text file

Reply to Message Icon

Name: AllenD
Date: December 4, 2008 at 15:50:25 Pacific
OS: XP
CPU/Ram: 512
Product: Dell / DELL
Comment:

I need help with script that shows uptime of 50 pc's. The script run once a week and it works but i would like the script to overwrite last week results. I have tried > but it doesn't write anything on results.txt any idea what i should do?

@ECHO OFF
for /f "tokens=* delims= " %%a in (c:\computer.txt) do (
uptime.exe %%a > \\pc12548\c$\results.txt
)




Sponsored Link
Ads by Google

Response Number 1
Name: klint
Date: December 5, 2008 at 01:44:00 Pacific
Reply:

I think it could be that it's overwriting results.txt every time through your loop. Try this instead:

(for /f "tokens=* delims= " %%a in (c:\computer.txt) do (
uptime.exe %%a
)) > \\pc12548\c$\results.txt


0

Response Number 2
Name: AllenD
Date: December 5, 2008 at 05:29:32 Pacific
Reply:

worked like charm. Thank you so much Klint


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







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: Bat script overwrite text file

Search for a line in a text file www.computing.net/answers/programming/search-for-a-line-in-a-text-file/19293.html

Editing text file thru bat www.computing.net/answers/programming/editing-text-file-thru-bat/15752.html

batch processing text files. www.computing.net/answers/programming/batch-processing-text-files/15280.html