How to create a batch file that appeals the copy file from original destination to copied destination, by using for, set, if and xcopy??? the file is drag from one directory to the batch file where the new directory located
联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!
@echo off
echo copy file %1...
pause
:: M-bkup.cmd - Backup files and directories preserving their full pathnames by Drag&Drop
:: Will Sort - 2005-09-18 - CMD@WinXP
:: Wrote according to request of Michael Ngen
:: Link: Chine DOS Union Forum - http://www.cn-dos.net/forum/viewthread.php?tid=16947
:: Update: 2005-10-26
@echo off & setlocal EnableExtensions
if not '%1'=='' goto GetPath
:Help
echo NO ACTION TAKEN
echo Usage: Drag and drop files or directories over this file.
echo.
goto End
:GetPath
for %%p in (%0) do set _base=%%~dpp
:Backup
for %%p in (%1.*) do echo File: %%~nxp && xcopy /d /f /g /h /k /r %1 %_base%%%~pp
for /d %%p in (%1.*) do echo Directory: %%~nxp && xcopy /d /e /f /g /h /i /k /r %1 "%_base%%%~pnxp"
if errorlevel 2 goto End
shift
if not '%1'=='' goto Backup
:End
pause