Copy Files to Remote Machines via Server List

@Echo off
Title Administrative Copy Engine
color 0a
Setlocal EnableDelayedExpansion

REM EXTERNAL VARIABLES
rem Server file(s) path
set Server=I:\temp\_Script_engine

rem Report name
Set report=Report.txt

rem Enter name of computer text file
Set PCList=server_list.txt

rem file name and remote path to be copied to
rem DO NOT ADD C:\. Add none for empty fields
Set file01=testfile.txt
Set path01=Users\%username%\Desktop

rem file name and remote path to be copied to
rem DO NOT ADD C:\. Add none for empty fields
Set file02=none
Set path02=none

rem file name and remote path to be copied to
rem DO NOT ADD C:\. Add none for empty fields
Set file03=none
Set path03=none

rem file name and remote path to be copied to
rem DO NOT ADD C:\. Add none for empty fields
Set file04=none
Set path04=none

rem file name and remote path to be copied to
rem DO NOT ADD C:\. Add none for empty fields
Set file05=none
Set path05=none

REM INTERNAL VARIABLES – do not edit below this line
rem —————————————————————————-

REM CREATES DATE AND TIME TIMESTAMP
for /F “tokens=2-4 delims=/- ” %%p in (‘date/T’) do set mdate=%%r%%p%%q
for /F “tokens=1-2 delims=:- ” %%p in (‘time/T’) do set mtime=%%p%%q

Set ReportN=%mdate%_%mtime%_%report%

cls
Echo Report name: %ReportN%
echo.
echo File Name 1: %file01%
echo Copy Path 1: %path01% && echo.

if %file02% NEQ none echo File Name 2: %file02%
if %file02% NEQ none echo Copy Path 2: %path02% && echo.

if %file03% NEQ none echo File Name 3: %file03%
if %file03% NEQ none echo Copy Path 3: %path03% && echo.

if %file04% NEQ none echo File Name 4: %file04%
if %file04% NEQ none echo Copy Path 4: %path04% && echo.

if %file05% NEQ none echo File Name 5: %file05%
if %file05% NEQ none echo Copy Path 5: %path05% && echo.

Echo The script engine reports these as your current settings
echo.

@rem gurantees you start in the right folder
cd\
cd %server%
pause

cls

REM PROGRAM ROUTINE
:CYCLE
for /f “tokens=* delims= ” %%a in (%PCList%) do (
echo Loading workstation name…
ping %%a | find “Reply” > nul
if errorlevel 1 (echo !date! !time! %%a, OFFLINE >> “%ReportN%”
echo %%a not found…
echo %%a>> “offline_machines.txt”
echo.
echo.
%windir%\system32\ping.exe -n 2 127.0.0.1>nul
) else (
echo !date! !time! %%a, ONLINE >> “%ReportN%”
echo Found %%a…
%windir%\system32\ping.exe -n 2 127.0.0.1>nul

echo Copying File 1: %file01% to %path01%…
%windir%\system32\ping.exe -n 2 127.0.0.1>nul
copy /y /v “%server%\files\%file01%” “\\%%a\c$\%path01%\”

if %file02% NEQ none echo Copying File 2: %file02% to %path02%…
if %file02% NEQ none %windir%\system32\ping.exe -n 2 127.0.0.1>nul
if %file02% NEQ none copy /y /v “%server%\files\%file02%” “\\%%a\c$\%path02%\”

if %file03% NEQ none echo Copying File 3: %file03% to %path03%…
if %file03% NEQ none %windir%\system32\ping.exe -n 2 127.0.0.1>nul
if %file03% NEQ none copy /y /v “%server%\files\%file03%” “\\%%a\c$\%path03%\”

if %file04% NEQ none echo Copying File 4: %file04% to %path04%…
if %file04% NEQ none %windir%\system32\ping.exe -n 2 127.0.0.1>nul
if %file04% NEQ none copy /y /v “%server%\files\%file04%” “\\%%a\c$\%path04%\”

if %file05% NEQ none echo Copying File 5: %file05% to %path05%…
if %file05% NEQ none %windir%\system32\ping.exe -n 2 127.0.0.1>nul
if %file05% NEQ none copy /y /v “%server%\files\%file05%” “\\%%a\c$\%path05%\”

echo Copy to %%a is complete.

rem CAN BE REMOVED TO SPEED UP COPYING
%windir%\system32\ping.exe -n 2 127.0.0.1>nul
echo.
echo.
)
)
pause
endlocal
exit /b 0

email me