Skip to content
⌘ NSIS Forum Archive

How to parse folder to find folder

7 posts

Socrate#

How to parse folder to find folder

Hello

I need to parse a folder to find subfolder.
I try to use FindFirst function but nothing is done. Maybe it's only for files.

Could you help me please ?
Afrow UK#
FindFirst and FindNext will return folder names as well.

For recursive searching, use RecFind (on wiki) or Locate (in docs)

Stu
Socrate#
I don't need to use a recursive function because I have to parse only one folder not its sons.

You say that FindFirst can work but in my script it doesn't.

Here my code :

ReadRegStr $2 HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" "Local AppData"
WriteINIStr "$INSTDIR\MyIni.ini" "COMMON" "Doc" $2
FindFirst $0 $1 "$2\"
WriteINIStr "$INSTDIR\MyIni.ini" "COMMON" "Sec" $1

Where is the matter ?
Socrate#
Well, I try your doce, and it doesn't find any subfolder.

It returns me "."

I think
FindFirst $0 $1 "$2\*"
doesn't work
Red Wine#
FindFirst works and FindNext works too, you may want to check out the documentation, and search the forum as well.
kichik#
"." and ".." are two special folders listed in almost every folder. The first, ".", is the same as the current folder so "C:\blah" is actually the same as "C:\blah\.". The second is the parent folder, so "C:\blah\.." is the same as "C:\".

Simply use FindNext until you get to a real folder or file name and skip those two.