Goto specific folder and do a command help!

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
xhai
Posts: 39
Joined: 13 Jun 2013 09:33

Goto specific folder and do a command help!

#1 Post by xhai » 08 Aug 2014 09:56

Hi guys I have been exploring coding but I can set the output the way I want..

Code: Select all

@echo off

:folder1
cd folder1
cd ../
cd program
copy ..\program\1.exe . >nul
copy ..\program\2.exe . >nul
Del 1.exe
goto :folder2

:folder2
cd folder2
cd ../
cd program
copy ..\program\1.exe . >nul
copy ..\program\2.exe . >nul
Del 2.exe
goto :folder3

:folder3
cd folder3
cd ../
cd program
copy ..\program\1.exe . >nul
copy ..\program\2.exe . >nul
Del 1.exe
Del 2.exe

pause



I want the program work like this goto folder1 and copy 1.exe and 2.exe from program, delete 1.exe in folder 1
next Goto folder2 copy 1.exe and 2.exe from program, delete 2.exe in the folder2
goto folder3 copy 1.exe and 2.exe from program, delete 1.exe and 2.exe in the folder3

The problem in my code was it doesn't move to the directory and copy files into folder1,folder2 and folder but instead it always delete the files in program folder..

Question when copying files larger than 1gb how fast it will copy also will it result to corruption when copying it..

Yury
Posts: 115
Joined: 28 Dec 2013 07:54

Re: Goto specific folder and do a command help!

#2 Post by Yury » 08 Aug 2014 11:55

Code: Select all

@echo off

:folder1
cd /d "D:\test1\folder1"
move "1.exe" "..\program\1.exe">nul
copy /b "..\program\2.exe">nul

:folder2
cd /d "D:\test2\folder2"
copy /b "..\program\1.exe">nul
move "2.exe" "..\program\2.exe">nul

:folder3
cd /d "D:\test3\folder3"
move "1.exe" "..\program\1.exe">nul
move "2.exe" "..\program\2.exe">nul

pause



???

Post Reply