Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

OT - Batch Files 4

Status
Not open for further replies.

MachineSMMC

Industrial
May 7, 2004
70
Good Morning

I know this is a little off topic but you guys are so smart I figured you could help me out.

I would like to create a batch file that will help me create folders. Basically every time I get a job I create a whole bunch of folders for that job.

ex. Job 100
NC Programs
Iges Files
Trodes
MC9 Files

I would like to be able to create a batch file that helps me do this faster. I would like it to prompt me for the job number then create all of the folders for me.

Any help would be greatly appreciated.

Thanks
Chris
 
Replies continue below

Recommended for you

You don't need a batch file for that. Just create the empty folders in Windows Explorer and copy the Top Level folder (Job XXX) to wherever you want, then rename it (Job 101).

[cheers]
Making the best use of this Forum. faq559-716
How to get answers to your SW questions. faq559-1091
Helpful SW websites every user should be aware of. faq559-520
 
I have a VB program that does this. If you want the source let me know and I'll shoot it your way. You'll have to have VB to compile it to an EXE though.

You might be able to do it through a batch file but I'm not sure you can make it prompt you for input and then pass that variable to the rest of the code.

Jason Capriotti
Smith & Nephew, Inc.
 
If I understand what you are after correctly, you can do something close to what you want with a batch file. Here’s a rough cut at it.

makedirs.bat

mkdir “Job %1”
mkdir “Job %1\NC Programs”
mkdir “Job %1\Iges Files”
mkdir “Job %1\Trodes”
mkdir “Job %1\MC9 Files”

Then with the makedirs.bat in the dir you want the Job xxx folder you would type:

makedirs 100

to create the directory and its subs. Basically the batch file replaces %1 with the first thing that you type after the name of the batch file.

 
EEnd

I cannot get this to work for me. It seems to be stuck in a loop. It just keeps cycling. It never creates the folders.

Please help.

Thanks
Chris
 
Use the KISS principle.

Just create the (empty) folder structure you want
Job XXX
NC Programs
Iges Files
Trodes
MC9 Files
using Windows Explorer, & save that on your Desktop (or wherever you want) to be used as a "template". Then whenever you want to start a new job, simply copy, paste & rename the Job XXX folder to the destination folder.

[cheers]
Making the best use of this Forum. faq559-716
How to get answers to your SW questions. faq559-1091
Helpful SW websites every user should be aware of. faq559-520
 
I agree that would work but it is not the fastest method, plus I have a couple of spots that I need to create folder structures at for the same job.

Chris
 
Now I'm curious ... what would be faster than "drag-n-drop, click & rename"?

Also, can you explain what you mean by "a couple of spots that I need to create folder structures at for the same job."

[cheers]
Making the best use of this Forum. faq559-716
How to get answers to your SW questions. faq559-1091
Helpful SW websites every user should be aware of. faq559-520
 
Creating a script that you would enter the Job number and it would create the folders automatically

Basically I have a folder where I store my mold designs and a seperate folder where I store all of my CNC programs.

Chris
 
MachineSMMC

I can see a couple of problems that could have occurred if you copied and pasted from my post into a batch file.

1) The makedirs.bat line should not be in the actual batch file. It is just the name that I made up for it. This could be the cause of the looping.

2) Somewhere along the line, the post got the fancy paired quote marks. I think it’s the result of creating the post in Word. In any case they need to be made into regular quote marks.

I’m going to try linking the batch file for you. Hopefully that will work.


Eric
 
Actually, you don't need any quotes.

When I run the bat file (with or without quotes) it creates the folders both inside & outside the Top Level folder. Any idea why that would be happening?

[cheers]
Making the best use of this Forum. faq559-716
How to get answers to your SW questions. faq559-1091
Helpful SW websites every user should be aware of. faq559-520
 
Jut figured out what was wrong. I forgot you cannot have spaces in the path name. The BAT file should be
Code:
mkdir Job_%1
mkdir Job_%1\NC_Programs
mkdir Job_%1\Iges_Files
mkdir Job_%1\Trodes
mkdir Job_%1\MC9_Files

I still think it is quicker & easier to rename then drag-n-drop ... 6 clicks using the bat file, 3 clicks using drag-n-drop ... but that's just my preference. Also I dislike having to use underscores.

[cheers]
Making the best use of this Forum. faq559-716
How to get answers to your SW questions. faq559-1091
Helpful SW websites every user should be aware of. faq559-520
 
This job can actually be done pretty easily with the windows scripting host using VBscript. Just make a .vbs file such as mkfolders.vbs, and use the following contents:


----CUT HERE----
Dim fso, num, jobfolder
num = InputBox("Enter job number")
Set fso = CreateObject("Scripting.FileSystemObject")
jobfolder = "Job " + num
fso.CreateFolder(jobfolder)
fso.CreateFolder(jobfolder + "\NC Programs")
fso.CreateFolder(jobfolder + "\Iges Files")
fso.CreateFolder(jobfolder + "\Trodes")
fso.CreateFolder(jobfolder + "\MC9 Files")
-----CUT HERE----

Just double-click that puppy and it'll prompt you for a number and make the folders in the current directory. You could even make shortcuts to it with different "Start in" directories for the different places you want your folders.

Jonathan Anderson
 
Jonathan

That is exactly what I was looking for.

Thanks
Chris
 
Jonathan

What do you mean by Start In? And How would I do this?

Chris
 
Jonathan

Do you know any good resources for learning this stuff?

Chris
 
Right click on the vbs file, and then create shortcut. Now right click and go to properties on the shortcut. There is a field that says "Start In" (the wording might be a little different on another version of Windows - I've got XP). That is the directory that the script will run in. So if the script was in C:\scripts or something, then you could make the shortcut with C:\projects in the "Start In" field, and when you ran it through that shortcut it would make the directories under C:\projects.

As far as resources go, msdn.microsoft.com is a good place for all things Microsoft. You can also search for something like "VBScript" or "windows script host". Specifically on MSDN, the main documentation page for the scripting is [URL unfurl="true"]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/scriptinga.asp[/url]

Jonathan Anderson
 
CorBlimeyLimey,

The quotes allow for the use of spaces in the directory names.

Eric
 
EEnd ... OK, I just figured out what I was doing wrong. I must have miskeyed when I copied the BAT file from your link. I must have had the original copy you posted, still in my clipboard, so pasted the wrong quotemarks again. It works fine now.
The VB Script from JonathanAnderson also works well & needs less clicks. I still prefer my method, but it's really a moot point as I don't use any of them anyway. [lol]

It's good to learn something new though. Thanks guys.

[cheers]
Making the best use of this Forum. faq559-716
How to get answers to your SW questions. faq559-1091
Helpful SW websites every user should be aware of. faq559-520
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor