Hi.
we have multiple rar files in folder d:/data files named as 001.rar, 002.rar, 003.rar, ...
Now i want this rar files to be copied on drive folder Y:/ where i have folders 001/002/003....
Copy specific rar file to specific folder in drive Y
I will highly thankful for help.
Copy Specific rar file to specific folder on drive
Moderator: DosItHelp
Re: Copy Specific rar file to specific folder on drive
This should work:
Don't forget: If you're putting this into a batch script, replace each percent sign with two percent signs.
Code: Select all
for %i in (D:\MyRarFiles\*.rar) do (copy %i Y:\%~ni\)
Re: Copy Specific rar file to specific folder on drive
Use this.
Code: Select all
@echo off
setlocal
set "src=d:\data"
set "dest=y:\"
2>nul cd /d "%src%"
if errorlevel 1 (
echo Source folder is not found or inaccessible.
goto :eof
)
2>nul pushd "%dest"%"
if errorlevel 1 (
echo Destination folder is not found or inaccessible.
goto :eof
)
popd
set num=1
:loop
set n=00%num%
set n=%n:~-3%
if exist %n%.rar (
echo %n%.rar =^> %dest%\%n%
2>nul md "%dest%\%n%"
>nul copy %n%.rar "%dest%\%n%"
if errorlevel 1 goto :eof
set /a num+=1
goto loop
)