@echo off REM The media_deassign_notify.cmd writes the tape number out to the text file REM REM The FOR command then parses the text file one line at a time FOR /F "tokens=6" %%i in (C:\Reports\MEDIA_DEASSIGNED.txt) do ( REM Query, right now, the status of the tape and write it to a text file REM This is to make sure the tape is still in the Scratch pool and has not REM been used since it was deassigned C:\Veritas\Volmgr\bin\vmquery -l -m %%i > c:\Reports\CHECK_STATUS.txt REM The FOR command then parses the text file and passes the variable, which is REM the volume pool, to the next command FOR /F "tokens=12" %%j in (C:\Reports\CHECK_STATUS.txt) do ( REM If the tape is in the Scratch pool, then bplabel, or erase it REM Otherwise, do nothing, skip it if "%%j"=="Scratch" C:\Veritas\Netbackup\bin\admincmd\bplabel -m %%i -d hcart -o -p Scratch -host "myhost" ) ) REM Rename file, appending time and date to filename if exist "C:\Reports\MEDIA_DEASSIGNED.txt" ren "C:\Reports\MEDIA_DEASSIGNED.txt" "MEDIA_DEASSIGNED_%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%.txt" REM Delete the text file that the vmquery created REM Not needed anymore if exist "C:\Reports\CHECK_STATUS.txt" del "C:\Reports\CHECK_STATUS.txt" /Q