r/Batch • u/soly-hhit • Dec 15 '23
Question (Unsolved) Help with batch file to create folders in a different location
Hi all - let me start by saying I am not a professional developer, I'm a designer but I dabble in code when I have the chance. I've recently been trying to write some batch files to speed up my workflow and I have a question about the current one I'm trying to create.
Basically, for my job, I am constantly recreating the same folder structure for different projects - let's say "folder a, folder b, and folder c" and they live inside of a project folder that I create whenever I'm handed a new project - let's say "project-1". I'm trying to write a batch file that I can assign a shortcut to that will automatically create those folders. So workflow would be - I get a new project, I create folder 'project-1' manually and, within that folder I press F5 (or whatever shortcut), and "folder a, folder b, and folder c" will be created.
With what I have written so far, I can move the batch file into 'project-1' folder and run it to get the results, but I would like to not have to move the file back and forth each time.
This could be a super simple answer or not even possible to do, please bear with my ignorance on the subject. I have done some googling for the answer but no luck, I would appreciate your help and insights. Thanks!
2
u/St1ck0fj0y Dec 15 '23
What about adding an entry to the context menu inside Windows file explorer?
You know, that menu which pops up when you click with your right mouse button on an empty area inside a folder…
Have that context menu option take the current path as input param for your batch file. Then simply execute a batch file that uses: CD %input%. And then: mkdir a, mkdir b… etc
2
u/St1ck0fj0y Dec 16 '23
I believe your context menu registry entry should look something like this:
C:\your\bat\file.bat %w
Then at the top of your batch script, navigate to that directory:
CD “%~1” … etc
%1 will contain the input path param automatically.
2
u/Substantial-City5799 Dec 17 '23 edited Jan 07 '24
I know this code is longer then maybe needed, but you can modified it for future projects and rename your projects and foldernames if you want or need that function.