递归搜索目录中的 sql 个文件 (NSIS)
Recursive search for sql files in directories (NSIS)
递归搜索有问题,但首先是一些关键数据:
- 我有几个目录,其中包含 sql 个文件,我想将这些文件复制到 $TEMP
- 我想从中读取的目录看起来像这样 v2.1.0.0
- 目前必须读取目录 v2.5.0.0 到 v2.7.0.3
- 文件夹不必是 "the next" 所以 v2.5.0.3 可以跟随 v2.5.0.0
- 我正在使用 LogicLib
- 我是这门语言的新手(在 java 之前),这是我的第一个任务
我目前正在尝试使用 ${ForEach}
解决问题
!macro GetSQLVersionFiles first second third fourth
SetOutPath $TEMP
${ForEach} ${first} 0 9 + 1
${ForEach} ${second} 0 9 + 1
${ForEach} ${third} 0 9 + 1
${ForEach} ${fourth} 0 9 + 1
IfFileExists "scripte\v${first}.${second}.${third}.${fourth}" 0 +2
File "scripte\v${first}.${second}.${third}.${fourth}\*.sql"
${next}
${next}
${next}
${next}
!macroend
所以我的想法是,为了以后可行,有一个带有 4 个参数的宏,可以在其中放置开始目录,比如所需的“2 5 0 0”,它遍历每个文件夹并放入将找到的 .sql 文件放入 $TEMP 目录
我已经尝试过的东西
- 引用没有{}的所有参数
- 写“${first} ${first} 9 + 1(以为这只会从 from first 迭代到 9)
我得到的错误如下
!insertmacro: _ForEach
Usage: StrCpy $(user_var: output) str [maxlen] [startoffset]
Error in macro _ForEach on macroline 3
Error in macro GetSQLVersionFiles on macroline 2
Error in script "\NAMEOFMYSCRIPT -- aborting creation process
LogicLib的_ForEach中的第三行是
StrCpy "${_v}" "${_f}" ; Assign the initial value
提前感谢您的帮助:)
您正在混合定义和变量。
定义使用 !define
创建并使用 ${name}
访问。
变量是用 Var
创建的,用 $name
访问的。您还可以使用一些内置变量:$0..$9.
变量可以在 run-time 处更改,定义不能。
另外一个问题是不能使用File
指令在end-users机器上复制文件,如果要复制文件需要使用CopyFiles
指令run-time。另一方面,如果您想从安装程序中提取文件(我无法根据您的问题确定您想要哪个),那么您确实需要使用 File
指令,但您不能使用 ${For}
因为它是一个 run-time 的概念。您可以使用 !system
到 然后 !include
.
递归搜索有问题,但首先是一些关键数据:
- 我有几个目录,其中包含 sql 个文件,我想将这些文件复制到 $TEMP
- 我想从中读取的目录看起来像这样 v2.1.0.0
- 目前必须读取目录 v2.5.0.0 到 v2.7.0.3
- 文件夹不必是 "the next" 所以 v2.5.0.3 可以跟随 v2.5.0.0
- 我正在使用 LogicLib
- 我是这门语言的新手(在 java 之前),这是我的第一个任务
我目前正在尝试使用 ${ForEach}
解决问题!macro GetSQLVersionFiles first second third fourth
SetOutPath $TEMP
${ForEach} ${first} 0 9 + 1
${ForEach} ${second} 0 9 + 1
${ForEach} ${third} 0 9 + 1
${ForEach} ${fourth} 0 9 + 1
IfFileExists "scripte\v${first}.${second}.${third}.${fourth}" 0 +2
File "scripte\v${first}.${second}.${third}.${fourth}\*.sql"
${next}
${next}
${next}
${next}
!macroend
所以我的想法是,为了以后可行,有一个带有 4 个参数的宏,可以在其中放置开始目录,比如所需的“2 5 0 0”,它遍历每个文件夹并放入将找到的 .sql 文件放入 $TEMP 目录
我已经尝试过的东西
- 引用没有{}的所有参数
- 写“${first} ${first} 9 + 1(以为这只会从 from first 迭代到 9)
我得到的错误如下
!insertmacro: _ForEach
Usage: StrCpy $(user_var: output) str [maxlen] [startoffset]
Error in macro _ForEach on macroline 3
Error in macro GetSQLVersionFiles on macroline 2
Error in script "\NAMEOFMYSCRIPT -- aborting creation process
LogicLib的_ForEach中的第三行是
StrCpy "${_v}" "${_f}" ; Assign the initial value
提前感谢您的帮助:)
您正在混合定义和变量。
定义使用 !define
创建并使用 ${name}
访问。
变量是用 Var
创建的,用 $name
访问的。您还可以使用一些内置变量:$0..$9.
变量可以在 run-time 处更改,定义不能。
另外一个问题是不能使用File
指令在end-users机器上复制文件,如果要复制文件需要使用CopyFiles
指令run-time。另一方面,如果您想从安装程序中提取文件(我无法根据您的问题确定您想要哪个),那么您确实需要使用 File
指令,但您不能使用 ${For}
因为它是一个 run-time 的概念。您可以使用 !system
到 !include
.