2013-07-06 105 views
0

我有一个字符串变量名$1这是一个路径(目录)。我需要在安装过程中将我的输出目录中的文件复制到$1。所以我这样做:如何获取目录中特定类型文件的名称?

SetOutPath $1 
File "Database\*.xxx" 

也就是说从Database文件夹$1.xxx类型的所有文件。但是我只有一个这种类型的文件。如何在另一个变量中获取该文件的名称?

例如,我Database文件夹看起来像:

Database -> 224eadf234.xxx 

我不想在NSIS脚本,因为它可以在其他未来的东西硬编码的基本名称224eadf234.xxx,但延长是怎么回事永远是.xxx。这就是为什么我去*.xxx的方法。但我确实需要在运行时获取文件的名称。由于目录Database中只有这样的文件,我认为它会很容易。

谢谢。

回答

1
!appendfile "$%temp%\tmp1234.xxx" "This is a test" ; Create dummy file 

; Find file at compile-time (on Windows) 
!tempfile NSH 
!system 'for %A IN ("$%temp%\*.xxx") DO echo !define THEFILE "%~A" > "${NSH}"' 
!include "${NSH}" 
!delfile "${NSH}" 
!undef NSH 
!error "FILE=${THEFILE}" 

Section 
!include LogicLib.nsh 
StrCpy $1 $instdir\test 
SetOutPath $1 
File "$%temp%\*.xxx" 

; Find file at run-time 
FindFirst $2 $3 "$1\*.xxx" 
${If} $3 != "" 
    DetailPrint "First *.xxx file = $3" 
${EndIf} 
FindClose $2 
SectionEnd 
相关问题