Reputation: 363
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%
Upvotes: 0
Views: 115
Reputation: 16226
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"
Upvotes: 0
Reputation: 6032
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.
Upvotes: 1