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

前端 未结 1 1486
一个人的身影
一个人的身影 2021-01-24 10:24

everyone. I am trying to include some \"parentdir\" with files to my installer. The thing is: I use /r parameter to include all files and folders, like this:

Fil         


        
相关标签:
1条回答
  • 2021-01-24 10:54

    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
    
    0 讨论(0)
提交回复
热议问题