Saved Bookmarks
| 1. |
Solve : batch loop? |
|
Answer» Code: [Select]@ECHO off The idea of the program is if a drive exists then to backup the drive to D:\backup but if the drive doesn't exist then the progaram should loop until it does. Any help appreciated as i clearly am making a stupid mistake. Looping the batch code until a drive exists might take a while. Might be better to INVENTORY the DRIVES and backup the ones that you find. Don't know your OS, so I took a guess you have the DISKPART utility. Code: [Select]@echo off for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "partition"') do ( xcopy %%i:\ d:\backup\%%ibackup /e /h /i /q /y ) I added a directory level for each drive backup. Good luck. Thanks for that but what I want is for it to automatically backup my USB drive every time i plug it in which is why i want it to keep trying until its plugged in. Is there a way to do this even if it isn't the best way?Code: [Select]:loop if exist "E:\NUL" goto found goto loop :found XCOPY F: D:\backup /E /H /I /Q /Y This isn't a batch but it may help, or give you an idea: http://www.backup4all.com/kb/configuring-a-backup-to-run-automatically-when-the-usb-drive-is-plugged-in-248.html for example, although it uses a program called "backup4all" you could use the autorun file to run a batch. |
|