How to get a list of sub folder Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
songdg
Posts: 568
Joined: 04 Oct 2017, 20:04

How to get a list of sub folder

16 Sep 2018, 21:47

I want to use FileSelectFolder to choose a folder and get all the subfolders under it.For example I choose the folder "E:\date" and get a path list ["E:\date\0820\", "E:\date\0821\", "E:\date\0822\"].
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: How to get a list of sub folder

17 Sep 2018, 02:50

Hi.
As I know, there is following command for your desired task.

Code: Select all

Loop, Files, FilePattern, Mode
With FileSelectFolder you should be able to choose desired directory (FilePattern).
Einfach nur ein toller Typ. :mrgreen:
garry
Posts: 3770
Joined: 22 Dec 2013, 12:50

Re: How to get a list of sub folder  Topic is solved

17 Sep 2018, 03:58

yes, example with loop,files ..

Code: Select all

;["E:\date\0820\", "E:\date\0821\", "E:\date\0822\"]
;--------------------------------------------------------
;preselect=C:\                                           ;- drive C
;preselect= ::{20d04fe0-3aea-1069-a2d8-08002b30309d}     ;- workplace all drives
PRESELECT  =%a_desktop%         ;- search from here
FileSelectFolder,MF,%PRESELECT%
if MF=
  return
transform,s,chr,34 
transform,c,chr,44 
Loop, Files,%mf%\*.*, DR
  {
  x := a_loopfiledir . "\" . A_LoopFileName
  e1 .= x . "`r`n"                   ;- example-1
  e2 .= s . x . s . c . a_space      ;- example-2
  }
stringtrimright,e2,e2,2  
msgbox,%e1%  
f1=test55.txt
ifexist,%f1%
  filedelete,%f1%
fileappend,[%e2%],%f1%
run,%f1%

ExitApp
esc::exitapp
songdg
Posts: 568
Joined: 04 Oct 2017, 20:04

Re: How to get a list of sub folder

18 Sep 2018, 22:11

divanebaba wrote:Hi.
As I know, there is following command for your desired task.

Code: Select all

Loop, Files, FilePattern, Mode
With FileSelectFolder you should be able to choose desired directory (FilePattern).
Thanks for your direction.
songdg
Posts: 568
Joined: 04 Oct 2017, 20:04

Re: How to get a list of sub folder

18 Sep 2018, 22:11

garry wrote:yes, example with loop,files ..

Code: Select all

;["E:\date\0820\", "E:\date\0821\", "E:\date\0822\"]
;--------------------------------------------------------
;preselect=C:\                                           ;- drive C
;preselect= ::{20d04fe0-3aea-1069-a2d8-08002b30309d}     ;- workplace all drives
PRESELECT  =%a_desktop%         ;- search from here
FileSelectFolder,MF,%PRESELECT%
if MF=
  return
transform,s,chr,34 
transform,c,chr,44 
Loop, Files,%mf%\*.*, DR
  {
  x := a_loopfiledir . "\" . A_LoopFileName
  e1 .= x . "`r`n"                   ;- example-1
  e2 .= s . x . s . c . a_space      ;- example-2
  }
stringtrimright,e2,e2,2  
msgbox,%e1%  
f1=test55.txt
ifexist,%f1%
  filedelete,%f1%
fileappend,[%e2%],%f1%
run,%f1%

ExitApp
esc::exitapp
Thanks for your help!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, doanmvu, RSable and 371 guests