Add parent folder name to folder created by script Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
andrewvanmarle
Posts: 15
Joined: 08 Jul 2019, 07:58

Add parent folder name to folder created by script

04 Dec 2019, 10:15

I'm using the below code to create a set of folders with the push of one button and it works like a treat. The onlly thing that would improve it would be to append the name of the parentfolder to one of the folders.

ex. among the list of folders to be created is the folder "Documenten". If I were to create folders in (for instance) C:\folders\subfolders\test, I'd want to create "Documenten test"

is that possible?

Code: Select all

#IfWinactive, ahk_class CabinetWClass ;Makes the script active only when explorer (window) is active...
 
^F6:: ;Ctrl+F6 hotkey...
 


folders = 						;this can also be read in from a txt file or and ini file and could also be separated by commas
(
Documenten
Presentatie
WWFT
Niet sturen
Meterstanden
)


	controlgettext,address,ToolbarWindow323,A ;get address from Navigation Bar...
	address:=RegExReplace(address,".+: ") ;Format it...

oVar := address					  ;or something like oVar := "c:\documents\somepath" 
;if errorlevel							  ;if "cancel" is pressed 		
;	exitapp

for k,v in StrSplit(folders,"`n","`r")
	FileCreateDir, % oVar "\" v  


 
return ;Declare the Hotkey/label's End... 
Thanks!!
rakesha002
Posts: 34
Joined: 04 Dec 2017, 00:11

Re: Add parent folder name to folder created by script

05 Dec 2019, 08:40

Hi,

I think this is what you want,

Code: Select all

#IfWinactive, ahk_class CabinetWClass ;Makes the script active only when explorer (window) is active...
 
^F6:: ;Ctrl+F6 hotkey...
 
folders = 						;this can also be read in from a txt file or and ini file and could also be separated by commas
(
Documenten
Presentatie
WWFT
Niet sturen
Meterstanden
)
	controlgettext,address,ToolbarWindow323,A ;get address from Navigation Bar...
	address:=RegExReplace(address,".+: ") ;Format it...

oVar := address					  ;or something like oVar := "c:\documents\somepath" 
;if errorlevel							  ;if "cancel" is pressed 		
;	exitapp

for k,v in StrSplit(folders,"`n","`r") {
	SplitPath, oVar, OfN
	FileCreateDir, % oVar "\" v " " OfN
}
Hope it helps
andrewvanmarle
Posts: 15
Joined: 08 Jul 2019, 07:58

Re: Add parent folder name to folder created by script

12 Dec 2019, 10:37

Amazing!!

what would it look like if the foldername were only to be appended to one folder (let's say documenten)

is that possible?
rakesha002
Posts: 34
Joined: 04 Dec 2017, 00:11

Re: Add parent folder name to folder created by script

17 Dec 2019, 10:30

Hi,

May be this, sorry for the late reply, i was a little busy
I think, I tried to understand your requirement

Code: Select all

#IfWinactive, ahk_class CabinetWClass ;Makes the script active only when explorer (window) is active...
 
^F6:: ;Ctrl+F6 hotkey...
 
folders = 						;this can also be read in from a txt file or and ini file and could also be separated by commas
(
Documenten
Presentatie
WWFT
Niet sturen
Meterstanden
)
	controlgettext,address,ToolbarWindow323,A ;get address from Navigation Bar...
	address:=RegExReplace(address,".+: ") ;Format it...

OfN := "Documenten"
oVar := "D:\New folder"					  ;or something like oVar := "c:\documents\somepath" 
;if errorlevel							  ;if "cancel" is pressed 		
;	exitapp

for k,v in StrSplit(folders,"`n","`r") {
	SplitPath, oVar, Parent
	OfN := (v = OfN) ? OfN " " Parent : v
	FileCreateDir, % oVar "\" OfN
}
andrewvanmarle
Posts: 15
Joined: 08 Jul 2019, 07:58

Re: Add parent folder name to folder created by script  Topic is solved

18 Dec 2019, 06:18

I solved it like this:

Code: Select all

#IfWinactive, ahk_class CabinetWClass ;Makes the script active only when explorer (window) is active...
 
^F6:: ;Ctrl+F6 hotkey...
 
folders = 						;this can also be read in from a txt file or and ini file and could also be separated by commas
(
Presentatie
WWFT
Niet sturen
Meterstanden
)
	controlgettext,address,ToolbarWindow323,A ;get address from Navigation Bar...
	address:=RegExReplace(address,".+: ") ;Format it...




oVar := address					  ;or something like oVar := "c:\documents\somepath" 
;if errorlevel							  ;if "cancel" is pressed 		
;	exitapp

for k,v in StrSplit(folders,"`n","`r") {
	SplitPath, oVar,
	FileCreateDir, % oVar "\" v
}

docdir = Documenten

for k,v in StrSplit(docdir,"`n","`r") {
	SplitPath, oVar, OfN
	FileCreateDir, % oVar "\" v " " OfN
}


 
return ;Declare the Hotkey/label's End... 

I just created the documenten folder separatly. and gave that the appendix of the parent directory.


solved!


The regular folders are in that

Return to “Ask For Help”

Who is online

Users browsing this forum: boiler, frosse, Frosti, malcev, navmesh, teadrinker, Zamfir and 69 guests