
Re: Using a batch file to backup data to an external drive h
Mobjack wrote:
@foxidrive: Currently we run the batch from an external drive and the data is backed up to the drive the batch file is run from. (For example, the batch files reside on the D: drive and that is also where it creates the UserData directory for the files to be put in.) What we want to do it run the batch file from the C: drive and be able to select the drive letter of the external drive via user input. We dont want to assume the external drive will be D: or E: or whatever.
You can place a file in the root of the external drive and then detect the drive letter from a batch file.
Place a blank text file in the root of the external drive called backup.flag and run this batch file from c:
Code:
@echo off
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 if exist "%%a:\backup.flag" set drv=%%a
echo the USB drive is on drive %drv%:
pushd "%drv%:\"
call "normal backup USB.bat"
popd