how to check for a file and append if it exists

Answered how to check for a file and append if it exists

  • Monday, November 19, 2012 11:21 PM
     
     

    i have a program that exports the system info(name, os, prorgrams installed, etc) to a text file on the desktop when you run it.  i would like to call this as a login script with a group policy object to all the computers in my network.  then i want to write a script to gather them to a text file on my server.  what i have so far is:

    copy c:\users\%username%\desktop\sysinfo.txt \\418-serv01\c:\sysinfo

    the problem i'm running into is if the file exists, how to get it to append the new information?  i was thinking a /a, but i think that's ascii in dos.  i can do it in linux, but that's because i was heavily into it in the 90's when command line ruled.  unfortunately, i work with windows now, and these little things get me sometimes. 

     

All Replies

  • Monday, November 19, 2012 11:29 PM
     
     Answered

    Here you go:

    type c:\users\%username%\desktop\sysinfo.txt  >> \\418-serv01\c$\sysinfo\%UserName%.txt

    Note also that you cannot use colons in UNC paths.