Skip to content
⌘ NSIS Forum Archive

EnumDir?

2 posts

nafigator#

EnumDir?

Such task: installed program creates profiles dir under user appdata folder.
It goes something like:
<appdata>\<prog.name>\Profiles\<1-not.predetermined>\<2-also.unknown>.

So I need to copy stuff to the last dir, but path is known only up to 'Profiles'. Can I somehow get the name of that dir2. Dir1 doesn't contain anything but dir2.

All I managed to come up with is:
ReadEnvStr $0 APPDATA
StrCpy $0 $0\<prog.name>\Profiles
FindFirst $1 $2 "$0\*.*"
DetailPrint $2
;returns "."
FindNext $1 $2
DetailPrint $2
;".."
FindNext $1 $2
DetailPrint $2
;<dir1>
FindClose $1
StrCpy $0 $0\$2
FindFirst $1 $2 "$0\*.*"[/COLOR]
FindNext $1 $2
FindNext $1 $2
FindClose $1
StrCpy $OUTDIR $0\$2
;gives me desired path
Is there more intelligent way of doing this?
kichik#
Nope. To enumerate directories you have to use FindFirst, FindNext and FindClose. You can always save the directory in the registry, an INI file or an environment variable if you want a faster method.