DonationCoder.com Software > Post New Requests Here
IDEA: Subfolder Creator
magician62:
Ideally AHK so I can learn.
A dropzone where one or more folders can be dropped from various source locations.
Dropzone creates one or more empty folders of user defined name(s) inside dropped folder(s).
Sounds simple, but is it?
Purpose is to allow pre-population of folder sets for subsequent use.
TIA
Nod5:
An example, just to see if I understand the request.
If the user drops the folder
C:\this\folder
on the GUI dropzone then the program should create
C:\this\folder\somesubfolder
C:\this\folder\anothersubfolder
C:\this\folder\third
And similarly create the same named subfolders if we drop the folder C:\other\directory and so on.
If that's it then AutoHotkey can do it.
But if you want to learn perhaps you'd like to give it a shot yourself first? Help on commands to use
https://autohotkey.com/docs/Tutorial.htm
https://autohotkey.com/docs/commands/Gui.htm
https://autohotkey.com/docs/commands/Gui.htm#GuiDropFiles
https://autohotkey.com/docs/commands/FileCreateDir.htm
magician62:
You have it correct
:up:
Although I have looked at AHK in the past only bits of it made sense. I still have a long, long way to go. :)
Nod5:
Ok, here is a basic version. You could enhance it in several ways: Edit the subfolder names of course; Add editboxes so the user can change subfolder names on each use; Change the color, font and look of the window; Accept dropping more than one folder at a time; and more. If you look up the commands on each line in the AutoHotkey manual you'll quickly get ideas on how to tweak things.
--- Code: Autohotkey ---#NoEnv#SingleInstance forceGui, font, s14 cBlack boldGui, Add, Text,x100 y120,Drop folderGui, Show, w300 h300, Subfolder Creatorreturn GuiDropFiles: Loop, parse, A_GuiControlEvent, `n, `r { folder := A_LoopField break } if !InStr(FileExist(folder), "D") return FileCreateDir, %folder%\subfolder name FileCreateDir, %folder%\another subfolder FileCreateDir, %folder%\subfolder 3return GuiClose:exitapp
Here is how it looks in Windows 10
magician62:
I like your use of "quickly ". It is a relative term, and the closer you get to retirement, the longer "quickly" takes. :)
From what you have there I can see how the GUI is created. In my working version I have moved the box creation to the top which seems to work, but is there a reason not to do this? To me the logical progression is make a box, chose pen and ink, and write something with it. :)
I created a gosub for folder creation and dropped it to the bottom with the appropriate entries for folder creation.
The bit I had trouble with is a loop for a group of folders dropped. I took a while before I realised that your "Break" might be stopping a Loop through all the folders dropped So tried substituting the gosub for the Break, and all seems to work!
--- Code: Autohotkey ---#NoEnv#SingleInstance forceGui, Show, w300 h300, Subfolder CreatorGui, font, s14 cBlack boldGui, Add, Text, x150 y150, Drop folder return GuiDropFiles: Loop, parse, A_GuiControlEvent, `n, `r { folder := A_LoopField gosub,create_folder } returnGuiClose:exitapp create_folder: if !InStr(FileExist(folder), "D") return FileCreateDir, %folder%\p01 FileCreateDir, %folder%\p02 FileCreateDir, %folder%\p03 FileCreateDir, %folder%\p04 FileCreateDir, %folder%\p05 FileCreateDir, %folder%\p06 FileCreateDir, %folder%\p07 FileCreateDir, %folder%\p08 FileCreateDir, %folder%\p09 FileCreateDir, %folder%\p10 FileCreateDir, %folder%\p11 FileCreateDir, %folder%\p12return
Navigation
[0] Message Index
[#] Next page
Go to full version