none
Copy file to server location and not have it overwrite existing file of the same name RRS feed

  • Question

  • I created a batch file to find computer specs and put them into a log file.  Then I have the log file being put on my user folder on the server.  Problem is I want to run this through a script in active directory to pull specs off all computers on the domain and each copy overrides the next because they have the same name.  I want to know if there is a way to not overwrite the file with the same exact name but instead make a "copy(1)," "copy(2)," etc.  Here is what my current batch file looks like:

    @echo off
    
    SET LOGFILE=SystemSpecs.log 
    call :test >> %LOGFILE% 
    exit /b 0
    
    :test
    
    wmic csproduct get identifyingnumber,name,vendor
    
    wmic os get osarchitecture
    
    wmic os get name
    
    wmic os get installdate
    
    wmic computersystem get name
    
    wmic computersystem get username
    
    wmic computersystem get totalphysicalmemory
    
    wmic baseboard get serialnumber
    
    wmic cpu get name
    
    @echo off
    
    xcopy systemspecs.log \\10.0.2.3\users\rricks\computerinfo 

    Any help would be greatly appreciated! 

    Tuesday, April 8, 2014 5:45 PM

Answers

  • Here you go:

    @echo off
    call :test >> \\10.0.2.3\users\rricks\computerinfo\%ComputerName%.log
    goto :eof

    :test
    wmic csproduct get identifyingnumber,name,vendor
    wmic os get osarchitecture
    wmic os get name
    wmic os get installdate
    wmic computersystem get name
    wmic computersystem get username
    wmic computersystem get totalphysicalmemory
    wmic baseboard get serialnumber
    wmic cpu get name


    Tuesday, April 8, 2014 6:05 PM

All replies

  • Here you go:

    @echo off
    call :test >> \\10.0.2.3\users\rricks\computerinfo\%ComputerName%.log
    goto :eof

    :test
    wmic csproduct get identifyingnumber,name,vendor
    wmic os get osarchitecture
    wmic os get name
    wmic os get installdate
    wmic computersystem get name
    wmic computersystem get username
    wmic computersystem get totalphysicalmemory
    wmic baseboard get serialnumber
    wmic cpu get name


    Tuesday, April 8, 2014 6:05 PM
  • You sir are a Saint!!! 

    Wish I would have came to you first and saved about 2 hours of my day messing with xcopy and robocopy.  This way is 10x more efficient.

    Thanks again!

    Tuesday, April 8, 2014 7:08 PM