This is my first time creating a batch file. I am trying to execute by adding all the following inside a batch file. however the flow stops at the for loop. these command works when directly executed on command prompt. And I am also facing error with the copy command
SET ROOT="C:\Rahul\Projects\sub-folder"
SET WEB1=%ROOT%\folder1\1.war
SET WEB2=%ROOT%\folder2\2.war
SET SOURCE=%WEB1% %WEB2%
SET TARGET=C:\Rahul\softwares\apache-tomcat-6.0.29\webapps\
c:
cd C:\Rahul\softwares\apache-tomcat-6.0.29
rmdir /q /s work\Catalina
cd webapps
FOR %i in ("*.war") do rmdir /q /s %~ni
FOR %i in ("*.war") do del /q /s %i
FOR %i in (%SOURCE%) do copy %i %TARGET%
FOR %i in ("*.war") do rmdir /q /s %~ni
will work in the command line but not in a batch. Inside a batch file you must replace %i
with %%i
. This should be it.
In my experience, it is more often easier to not use quoting in the SET
statement. Then, use quoting whenever it is used.
SET THEVAR=C:\Program Files
DIR "%THEVAR%\Common Files"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.