×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

OT - Batch Files
4

OT - Batch Files

OT - Batch Files

(OP)
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

RE: OT - Batch Files

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).


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

RE: OT - Batch Files

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.

RE: OT - Batch Files

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.

RE: OT - Batch Files

(OP)
Gildashard

Send it my way.

Thanks
Chris

RE: OT - Batch Files

(OP)
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

RE: OT - Batch Files

Use the KISS principle.

Just create the (empty) folder structure you want

Quote:

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.


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

RE: OT - Batch Files

(OP)
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

RE: OT - Batch Files

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."


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

RE: OT - Batch Files

(OP)
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

RE: OT - Batch Files

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.

http://home.comcast.net/~onyxeye/SolidWorks/makedirs.bat

Eric

RE: OT - Batch Files

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?


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

RE: OT - Batch Files

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.


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

RE: OT - Batch Files

2
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

RE: OT - Batch Files

(OP)
Jonathan

That is exactly what I was looking for.

Thanks
Chris

RE: OT - Batch Files

(OP)
Jonathan

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

Chris

RE: OT - Batch Files

(OP)
Jonathan

Do you know any good resources for learning this stuff?

Chris

RE: OT - Batch Files

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 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/scriptinga.asp

Jonathan Anderson

RE: OT - Batch Files

CorBlimeyLimey,

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

Eric

RE: OT - Batch Files

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.

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


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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources