Set backup destination based on drive label #
instead of drive letter within a batch file:
@ECHO OFF
REM change your_label to your backup drive label
Set DSTV=your_label
Set DST=
For %%a IN (D: E: F: G: H: I: J: K: L: M: N: O: P: Q: R: S: T: U: V: W: X: Y: Z:) ^
DO (vol %%a 2> nul|Find /i "%DSTV%" > nul && Set DST=%%a)
REM if drive label not found, abort
If "%DST%"=="" Goto END
REM use %DST%\desired_subdir as destination
"C:\Program Files\fc\FastCopy.exe" /CMD=diff /force_close "c:\impt" /to="%DST%\impt"
:END
Exit
Notes:
- Credit: Amsith
- FastCopy (an outstanding open source file copier) was used in this example, though XCOPY, XXCOPY, Robocopy, or any app with command line support should work.
- The caret symbol (^) is used above for line continuation, but can also be used to escape reserved shell characters. More info.
- See also: Control USB drive letter assignment.
/windows | Oct 03, 2013
Subscribe or visit the archives.