2011-10-24 17 views
1

現在、以下に示す$ INSTDIR内のすべてのテキストファイルを検索するためのチェックがあります。NSISすべての.txtファイルを検索

ただし、追加の.txtファイルを含む$ INSTDIR \ mySubなどのサブディレクトリが存在する可能性があります。同様のループ構造を維持する方法もありますが、すべてのサブディレクトリも検索しますか?

FindFirst $R0 $R1 "$INSTDIR\*.txt" 
IfErrors ExitInstaller 0 
LoopIt: 
    Messagebox MB_OK "Do some processing on $R1" 
    FindNext $R0 $R1 
    IfErrors 0 LoopIt 

答えて

2
Function ProcessTextFiles 
Exch $0 
Push $1 
Push $2 
FindFirst $1 $2 "$0\*.txt" 
loop: 
    IfErrors end 
    DetailPrint 'Found "$0\$2"' 
    FindNext $1 $2 
    goto loop 
end: 
FindClose $1 
FindFirst $1 $2 "$0\*.*" 
dirloop: 
    IfErrors dirend 
    IfFileExists "$0\$2\*.*" 0 dirnext 
    StrCmp $2 "." dirnext 
    StrCmp $2 ".." dirnext 
    Push "$0\$2" 
    call ${__FUNCTION__} 
dirnext: 
    FindNext $1 $2 
    goto dirloop 
dirend: 
FindClose $1 
Pop $2 
Pop $1 
Pop $0 
FunctionEnd 

section 
push "$InstDir" 
call ProcessTextFiles 
sectionend 
+0

サイレントモードでは何か違いはありますか? http://stackoverflow.com/questions/8215733/nsis-find-files-in-silent-mode-not-working – jkh

1

代わりにLocate機能を使用するようにしてください。これははるかに良い解決策です。サブディレクトリの有無(またはサブディレクトリなし)、マスクの定義などのオプションを記述することができます。 docと例については、http://nsis.sourceforge.net/Locateを参照してください。

関連する問題