Question : How can I modify a batch script backup tool (using xcopy), to pull a list of drive paths from a file?

I am using the below script as a backup tool, but want to change the local drive option to pull from a list (txt, ini file or similar). So if I add a new backup path it would pick this up when next run.

@echo off
:: variables
set localdrive=D:\List.txt
set networkdrive=C:\Documents and Settings\srv_mclarn\Desktop\Backup
set backupcmd=xcopy /y /d /e /c /i /f /h /k /o /v /s

echo.
echo ---------------------------------------
echo Backing up D Drive...
echo ---------------------------------------

echo.
echo.
echo.
%backupcmd% "%localdrive%" "%networkdrive%"


echo.
echo.
echo.
echo Backup Complete!

echo.
@pause

Answer : How can I modify a batch script backup tool (using xcopy), to pull a list of drive paths from a file?

@echo off
:: variables
set localdrive=D:\List.txt
set networkdrive=C:\Documents and Settings\srv_mclarn\Desktop\Backup
set backupcmd=xcopy /y /d /e /c /i /f /h /k /o /v /s

echo.
echo ---------------------------------------
echo Backing up D Drive...
echo ---------------------------------------

echo.
echo.
echo.
for /f %%F in ('type %localdrive%') do %backupcmd% "%%F" "%networkdrive%"


echo.
echo.
echo.
echo Backup Complete!

echo.
@pause
Random Solutions  
 
programming4us programming4us