@echo off
chcp 1251
Setlocal EnableDelayedExpansion
net use delete /yes
net use z: \\ip.add.res.host\folder /PERSISTENT:NO /user:triumf.local\user pass
set srv_folder=path\
set Backup_folder=path\
set Backup_folder_2=path\
for /f "usebackq tokens=*" %%a in (`dir /b %Backup_folder%`) do call :DelFromBackup_folder "%%a"
for /f "usebackq tokens=*" %%b in (`dir /b %Backup_folder_2%`) do call :DelFromBackup_folder_2 "%%b"
for /f "usebackq tokens=*" %%c in (`dir /b %srv_folder%`) do call :DelFromsrv_folder "%%c"
robocopy %srv_folder% %Backup_folder% /s /LOG+:%Backup_folder_2%robolog.txt
robocopy %srv_folder% O:\ /s /log+:%Backup_folder%robolog.txt
goto :eof
pause
:DelFromBackup_folder
set /a y=0
for /f "usebackq tokens=*" %%d in (`dir /t:w /o:-d /b %Backup_folder%%~1%`) do (
set /a y+=1
if !y! GTR 4 (del %Backup_folder%%~1\%%d)
)
:DelFromBackup_folder_2
set /a y=0
for /f "usebackq tokens=*" %%e in (`dir /t:w /o:-d /b %Backup_folder_2%%~1%`) do (
set /a y+=1
if !y! == 0(del %Backup_folder_2%%~1\%%e)
)
:DelFromsrv_folder
set /a y=0
for /f "usebackq tokens=*" %%f in (`dir /t:w /o:-d /b %srv_folder%%~1%`) do (
set /a y+=1
if !y! GTR 1 (del %srv_folder%%~1\%%f)
)
exit /b
@echo off
Setlocal EnableDelayedExpansion
set srv_folder=c:\srv\
NET USE O: \\10.10.10.103\backup.srv /PERSISTENT:NO /User:domain.local\cooladmin greatpass
set Backup_folder=O:\
set local_folder=c:\bak\
for /f "usebackq tokens=*" %%a in (`dir /b %Backup_folder%`) do call :DelFromBackup_folder "%%a"
for /f "usebackq tokens=*" %%a in (`dir /b %srv_folder%`) do call :CopyToBackup_folders "%%a"
pause
goto :eof
:DelFromBackup_folder
set /a y=0
for /f "usebackq tokens=*" %%b in (`dir /t:w /o:-d /b %Backup_folder%%~1`) do (
set /a y+=1
if !y! GTR 4 (echo " del " %Backup_folder%%~1\%%b)
)
exit /B
:CopyToBackup_folders
set /a y=0
for /f "usebackq tokens=*" %%b in (`dir /t:w /o:-d /b %srv_folder%%~1`) do (
set /a y+=1
if !y! ==1 (echo "copy " %srv_folder%%~1\%%b " " %Backup_folder%%~1\%%b)
if !y! GTR 1 (echo "del " %srv_folder%%~1\%%b)
if !y! GTR 1 (echo "del " %local_folder%%~1\%%b)
if !y! ==1 (echo "copy " %srv_folder%%~1\%%b %local_folder%%~1\%%b)
)
exit /B
wmic /namespace:\\root\wmi PATH MSAcpi_ThermalZoneTemperature get CurrentTemperature