dos scripts
dos scripts hugo
1. dos copy batch script
for /f "delims=" %%I in (4.txt) do echo D| xcopy "D:\Apache Software Foundation\Tomcat 7.0\webapps\DigiUpload\segments\%%I" "D:\Pramod_temp\[[batch]] copy files\MissingSegments\Grade5\%%I" /s /i
2. dos copy batch script - 2
- Q: I need to copy those folders from d:\CtxProfile\User..\Downloads to the users actual home folder on shared dir Ans: You can use below batch, assuming that the folder in the other server is served using Windows Share. e.g. \ServerName\ShareName\file\home{username}\Downloads
@echo off
setlocal
set CtxProfilePath=D:\CtxProfile
set CtxProfileDownloadPath=Win10RS2v6\UPM_Profile\downloads
::note: CtxProfileDownloadPath is a path relative to CtxProfilePath
::i.e.: %CtxProfilePath%\{user}\%CtxProfileDownloadPath%
set RemoteShare=\\ServerName\ShareName
set RemoteUserHomePath=file\home
set RemoteUserDownloadPath=Downloads
::note: RemoteUserHomePath and RemoteUserDownloadPath are paths relative to RemoteShare
::i.e.: %RemoteShare%\%RemoteUserHomePath%\{user}\%RemoteUserDownloadPath%
for /d %%U in ("%CtxProfilePath%\*") do (
if "%~1" == "/copy" (
xcopy /i /s /y "%%U\%CtxProfileDownloadPath%" "\\%RemoteShare%\%RemoteUserHomePath%\%%~nxU\%RemoteUserDownloadPath%"
) else (
echo xcopy /i /s /y "%%U\%CtxProfileDownloadPath%" "\\%RemoteShare%\%RemoteUserHomePath%\%%~nxU\%RemoteUserDownloadPath%"
)
)
- The batch uses XCOPY to copy the folders, and will simply displays the XCOPY command line that will be executed, unless a /copy switch is specified on the batch command line (e.g. CopyDownloads.bat /copy). So, make sure the command line use the correct paths for both source folder and destination folder, before specifying the /copy switch.
3. dos while read
@echo off
for /f "tokens=*" %%a in (input.txt) do call :processline %%a
pause
goto :eof
:processline
echo line=%*
mkdir %*
goto :eof
:eof