NSIS - how to recursively include all files only from source folder and subfolders?

爷,独闯天下 提交于 2019-12-02 07:22:37

You can create a batch file (or any other program) that searches the disk and writes File instructions to a .nsh file. Your .nsi would first use !system to execute the external application that generates the .nsh and then !include it:

Section
SetOutPath "$INSTDIR\parentdir"
!tempfile filelist
!system '"generatefilelist.bat" ".\parentdir" "${filelist}"'
!include "${filelist}"
!delfile "${filelist}"
SectionEnd

...and the batch-file might look something like this:

@echo off
FOR /R "%~1" %%A IN (*.txt) DO (
    >> "%~2" echo.File "%%~A"
)

If the pattern is simple enough you don't need a separate batch-file, you can just use cmd.exe directly:

Section
SetOutPath "$INSTDIR\parentdir"
!tempfile filelist
!system 'FOR /R ".\parentdir" %A IN (*.txt) DO @( >> "${filelist}" echo.File "%~A" )'
!include "${filelist}"
!delfile "${filelist}"
SectionEnd
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!