-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpolyclone.bat
46 lines (35 loc) · 912 Bytes
/
polyclone.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
@echo off &setlocal
set /p "template= Enter Template Folder: "
set /p "newname= Enter New Name: "
set /p "description= Enter Description: "
echo Creating new element named "%newname%"
md %newname%
for %%i in (%template%\*.*) do (
set "filename=%%~ni"
set ex=%%~xi
if %template%==%%~ni (
call:WriteFile %template%\%%~ni%%~xi %newname%\%newname%%%~xi
) else (
call:WriteFile %template%\%%~ni%%~xi %newname%\%%~ni%%~xi
)
)
GOTO:EOF
:WriteFile
echo Writing %~1 to %~2
set "search=${NAME}"
set "search2=${DESCRIPTION}"
set "replace=%newname%"
set "replace2=%description%"
set "textfile=%~1"
set "newfile=%~2"
(for /f "delims=" %%i in ('findstr "." "%textfile%"') do (
set "line=%%i"
setlocal enabledelayedexpansion
set "line=!line:%search%=%replace%!"
set "line=!line:%search2%=%replace2%!"
echo(!line!
endlocal
))>"%newfile%"
GOTO:EOF
:EOF
echo Done!