IT Knowledge Base

User Tools

Site Tools


Contact me at for any feedback or suggestions.

My other sites:

Search all my sites:


Script to record backup disk changes

@echo off
set driveletter=G
set working=C:Scripts
set log=%working%Backup-disk.log
set thedate=%date:Mon =%
set thedate=%thedate:Tue =%
set thedate=%thedate:Wed =%
set thedate=%thedate:Thu =%
set thedate=%thedate:Fri =%
set thedate=%thedate:~6,4%/%thedate:~3,2%/%thedate:~0,2%
set thetime=%time:~0,2%:%time:~3,2%:%time:~6,2%
set datestamp=%thedate:/=%%thetime::=%
set datestamp=%datestamp: =%
if not exist %driveletter%:diskid2.txt echo %datestamp% > %driveletter%:diskid2.txt
set /p diskid=<%driveletter%:diskid2.txt
REM :: remove any spaces from the diskid:
set diskid=%diskid: =%
if not exist %working%lastdisk.txt echo None > %working%lastdisk.txt
set /p lastdisk=<%working%lastdisk.txt
if not exist %driveletter%:diskid2.txt (
     echo %thedate% - %thetime% - NO DISK FOUND at drive letter %driveletter% >> %log%
if %diskid%==%lastdisk% (
     echo %thedate% - %thetime% - Disk was not changed since last check >> %log%
if not %diskid%==%lastdisk% (
     echo %thedate% - %thetime% - The disk at drive letter %driveletter% was changed to: %diskid% >> %log%
     echo %diskid% > %working%lastdisk.txt
script_to_record_backup_disk_changes.txt · Last modified: 2018/04/09 09:56 (external edit)