Archive: How to find list of directories?


How to find list of directories?
I need to find the list of subfolders under a specified folder and then copy files from each of them.

How do I do that? (i.e. first, find a list of subfolders and then iterate through them).

I presume FindFirst / FindNext works only with files? Or can it be used with directories as well? How can I differentiate between a file and a directory if it can be used for both?

Thanks


Oops, found some more info after more digging...guess I have to use Locate plugin.

But I am running into compilation errors with it:
-------------------------------------
!include "FileFunc.nsh"

Section "Web Services" SEC02
SetOverwrite on

;Web services
SetDetailsPrint listonly
DetailPrint "Installing Web Services..."
SetDetailsPrint textonly
${Locate} "C:\Inetpub\wwwroot\CRI\" "/L=D" "InstallWebService"

SectionEnd

Function InstallWebService
DetailPrint "Found $R9"
Sleep 1000
FunctionEnd
-------------------------------
Gives me an error on the ${Locate} line:

Invalid command: ${Locate}
Error in script "ServerInstaller.nsi" on line 80 -- aborting creation process

Why is it rejecting the ${Locate} command if I have the proper .nsh file included?

!include "FileFunc.nsh"


-------------------------------------
!include "FileFunc.nsh"
!insertmacro Locate

Section "Web Services" SEC02
SetOverwrite on

;Web services
SetDetailsPrint listonly
DetailPrint "Installing Web Services..."
SetDetailsPrint textonly
${Locate} "C:\Inetpub\wwwroot\CRI\" "/L=D /G=0" "InstallWebService"

SectionEnd

Function InstallWebService
DetailPrint "Found $R9"
Sleep 1000

Push 0
FunctionEnd
-------------------------------

Thank you, that made it work.

But, unfortunately I have another issue. Can you pass a variable to a File command (i.e. so it picks up the files to process from a soft-coded list)?

it doesn't seem to be working for me, I get an error saying no files found:

Section "Web Services" SEC02
SetOverwrite on

;Web services
SetDetailsPrint listonly
DetailPrint "Installing Web Services..."
SetDetailsPrint textonly
${Locate} "C:\Inetpub\wwwroot\CRI" "/L=D /G=0" "InstallWebService"

SectionEnd

VAR SERVICE_DIR
VAR SERVICE_PATH

Function InstallWebService
${GetFileName} $R9 $SERVICE_DIR
StrCpy $SERVICE_PATH $R9

SetDetailsPrint listonly
DetailPrint "Installing $SERVICE_DIR..."
SetDetailsPrint textonly

SetOutPath "$WEBSERVICE_ROOT_DIRECTORY\$SERVICE_DIR"

File /r "$SERVICE_PATH\*.*" ///ERROR HAPPENS HERE

;Move on to next web service directory
Push $0
FunctionEnd
-------------------------------------
File: "$SERVICE_PATH\*.*" -> no files found.
Usage: File [/nonfatal] [/a] ([/r] [/x filespec [...]] filespec [...] |
/oname=outfile one_file_only)
Error in script "ServerInstaller.nsi" on line 108 -- aborting creation process

Does this mean I cannot use File the way I want it? (i.e. to find all folders on my box that correspond to a particular naming scheme and install them all without having to hard-code the list of them?).


Yes, you can't. "File" is compile-time command, NSIS variables are run-time.