Wednesday, April 20, 2016

Batch file to delete Folder and files by setting the parameter of the folder

Sample : https://www.dropbox.com/s/cvwltunpvwqxa3l/call%201.bat%20Brighton_v45.bat?dl=0


Code:
@echo off
setlocal EnableDelayedExpansion
cls
ECHO You are running: %0 %1 %date% %time%
REM set param1=%~1
set param1=Brighton_v45
set MYDIR=C:\
set tempPath=c:\%param1%\src\ProfilingSetup
set f1="%tempPath%\Default Configuration"
set f2="%tempPath%\Script Files\*.*"
set srcfile="%tempPath%\Script Files\setup.rul*"
set destfile="%tempPath%\setup.rul*"
set srcfiles="%tempPath%\String1033.txt*"
set destfiles="%tempPath%\Script Files\String1033.txt*"
for /F %%i in ('dir /B/D %MYDIR%') do call :Foo %%i
goto END

:Foo
set z=%1
if "%z%"=="%param1%" (
REM echo z set
echo %param1%
@RD /S /Q %f1%
xcopy /f /y %srcfile% %destfile%
del /s /q %f2%
xcopy /f /y %destfile% %srcfile%
xcopy /f /y %srcfiles% %destfiles%
del /q %tempPath%
xcopy /f /y %destfiles% %srcfiles%
del /q %destfiles%
)
goto :eof


:End