![]() |
#1 |
Junior Member
Join Date: Feb 2011
Posts: 4
|
Getting list of subfolders in a folder
Hello all,
Can you please tell me if there's a NSIS script to get a list or get the name, one at a time, of each subfolder inside a folder? Only one level below. As in input -> $DOCUMENTS Output: C:\Users\..\My Documents\My Pictures C:\Users\..\My Documents\My Music C:\Users\..\My Documents\Downloads... ...and so on. I even tried redirecting the output of 'dir "$DOCUMENTS" /ad /b > "$INSTDIR\directories.txt"' with nsExex::Exec and plain Exec... to no avail. If the file was created, all I'd have to do is a loop to read each line from it, but I didn't manage to get that to work either. Thanks in advance. |
![]() |
![]() |
![]() |
#2 |
Major Dude
Join Date: Oct 2006
Posts: 1,892
|
FindFirst $0 $1 "$INSTDIR\*.*"
loop: StrCmp $1 "" done ${If} ${FileExists} "$1\*.*" DetailPrint "Subdir found: $1" ${EndIf} FindNext $0 $1 Goto loop done: FindClose $0 |
![]() |
![]() |
![]() |
#3 |
Junior Member
Join Date: Oct 2016
Posts: 1
|
There's minor flaw that can cause you hours to debug in above code, here's a "7 hours worth" of fix:
FindFirst $0 $1 "$INSTDIR\*.*" loop: StrCmp $1 "" done ${If} ${FileExists} "$INSTDIR\$1\*.*" DetailPrint "Subdir found: $INSTDIR\$1" ${EndIf} FindNext $0 $1 Goto loop done: FindClose $0 Yeah, that "$INSTDIR\" omission makes the above codes only get two subdirs: . (current) and .. (parent). ...And got me really anxious for 7 hours! Damn, I'm such a dummy coder. |
![]() |
![]() |
![]() |
|
Tags |
dir, exec, folder, prompt, subfolder |
Thread Tools | Search this Thread |
Display Modes | |
|
|