[英]NSIS - How to install multiple files with similar folder structures using a single command?
I have multiple files in very similarly structured folders that I want to install in one common folder.我在结构非常相似的文件夹中有多个文件,我想将它们安装在一个公共文件夹中。
I can do this by manually specifying each file I want to add, like so:我可以通过手动指定要添加的每个文件来做到这一点,如下所示:
SetOutPath "$INSTDIR\Final\Destination"
File /r ".\ParentFolder\Folder1\Same\Path\For\All\Thing1.ext"
File /r ".\ParentFolder\Folder2\Same\Path\For\All\Thing2.ext"
File /r ".\ParentFolder\Folder3\Same\Path\For\All\Thing3.ext"
File /r ".\ParentFolder\Folder4\Same\Path\For\All\Thing4.ext"
File /r ".\ParentFolder\Folder5\Same\Path\For\All\Thing5.ext"
However, there are 50+ of these files, and they are likely to change, so I'd prefer to do this in a way that won't require editing the NSIS in the future.但是,这些文件有 50 多个,而且它们很可能会更改,所以我更愿意以一种将来不需要编辑 NSIS 的方式来执行此操作。
I tried putting in wildcards, like so:我尝试放入通配符,如下所示:
SetOutPath "$INSTDIR\Final\Destination"
File /r ".\ParentFolder\*\Same\Path\For\All\*.ext"
However, I get the message File: ".\ParentFolder\*\Same\Path\For\All\*.ext" -> no files found.
但是,我收到消息
File: ".\ParentFolder\*\Same\Path\For\All\*.ext" -> no files found.
Is there something wrong with using multiple wildcards *
in my File
query?在我的
File
查询中使用多个通配符*
有什么问题吗?
What would be the correct way to query multiple files in different folders?查询不同文件夹中的多个文件的正确方法是什么?
You can't put wildcards anywhere, only in the filename unfortunately.不幸的是,您不能在任何地方放置通配符,只能在文件名中放置。
What you can do however is to use !system
to execute a batch file (or any other command or application) that writes NSIS instructions to a file you can !include
:然而,你可以做的是使用
!system
来执行一个批处理文件(或任何其他命令或应用程序),将 NSIS 指令写入一个文件,你可以!include
:
Section
SetOutPath $InstDir
!tempfile folders ; temporary .nsh
!system 'for /D %A in (.\ParentFolder\*) do @>>"${folders}" echo File /r "%~A\Same\Path\For\All\*.ext"'
!include "${folders}"
!delfile "${folders}"
SectionEnd
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.