-
Notifications
You must be signed in to change notification settings - Fork 39
/
makensiscode.bat
61 lines (48 loc) · 1.43 KB
/
makensiscode.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
::chcp 65001
cd /d %~dp0
@set DestPath=%cd%\FilesToInstall\
@echo off& setlocal EnableDelayedExpansion
@set DestFiles=%cd%\SetupScripts\app.nsh
if exist %DestFiles% del /f %DestFiles%
@set total=1
@echo off
@rem 统计文件总数
for /f "tokens=*" %%a in ('dir /s/b/a-d %DestPath%') do (
@set /a total+=1
)
@set curr=0
@set tmpValue=1
@rem 做首级目录处理
for /f "delims=*" %%d in ('dir /a-d/b %DestPath%') do (
set /a curr+=1
@echo Push !total! >> %DestFiles%
@echo Push !curr! >> %DestFiles%
@echo Call ExtractCallback >> %DestFiles%
@echo File "%DestPath%%%d" >> %DestFiles%
@rem @echo "%%d"
)
@rem 循环遍历各个子目录,进行处理,生成NSIS指令
@set dstString=
for /f "delims=*" %%a in ('dir /s/ad/b %DestPath%') do (
@set foldername=%%a
@set "foldername=!foldername:%DestPath%=%dstString%!"
@rem @echo !foldername!
@rem 截取出来相关的目录 设置OutputPath
@echo SetOutPath "$INSTDIR\!foldername!" >> %DestFiles%
@rem 判断文件夹是否为空
dir /a /s /b %%a | findstr . >nul && (
@rem 循环其下的文件
for /f "delims=*" %%c in ('dir /a-d/b %%a') do (
@set /a curr+=1
@echo Push !total! >> %DestFiles%
@echo Push !curr! >> %DestFiles%
@echo Call ExtractCallback >> %DestFiles%
@echo File "%%a\%%c" >> %DestFiles%
@rem @echo "%%c"
)
)
)
@echo Push %total% >> %DestFiles%
@echo Push %total% >> %DestFiles%
@echo Call ExtractCallback >> %DestFiles%
::chcp 936