Beer glass scene creation
This course contains a little bit of everything with modeling, UVing, texturing and dynamics in Maya, as well as compositing multilayered EXR's in Photoshop.
# 1 07-11-2003 , 02:10 AM
Darkware's Avatar
Subscriber
Join Date: Oct 2002
Location: USA
Posts: 1,172

help with batch files. (.bat)

I'm trying to learn how to make batch files on my own so I can easily do certain things on my computer like erase my temporary internet files with a single click of the mouse, but am running into trouble.

First of all, for those of you who don't know the first thing about batch files:
-you save them as .bat An example is filenumberone.bat
-They have about 8 basic commands that are fairly easy to learn.
-by executing a batch file, you can do several things at once.

Now, right now, I'm just in the testing phase, so I created a directory.

C:\Documents and Settings\Administrator\Desktop\Master\TESTMAIN\TES TSUB

The command I'm using in the batch file (erase.bat) is

del C:\Docume~1\Admini~1\Desktop\Master\TESTMAIN\TESTS UB

The reason I changed the first two directories with a ~1 at the end is because batch files are run through DOS. DOS does not like file names with more than 8 characters. It automatically recognizes the files in their abreviated form.

Now, this works, but it only deletes files IN the directory. What I'm wanting to know is if there is a way to delete the actual FOLDERS - not just the files inside the folders.

Any ideas?

# 2 07-11-2003 , 02:46 AM
Darkware's Avatar
Subscriber
Join Date: Oct 2002
Location: USA
Posts: 1,172
nevermind. I figured it out. I needed the deltree command, but that particular command is not in windows 2000, so I have to stick /s /q at the end of RD C:\docume~1 blahblahblah

Stick around though. I might have some other problems that need fixing. lol

# 3 07-11-2003 , 08:53 AM
dave_baer's Avatar
Moderator
Join Date: Sep 2002
Location: Plantation, Florida
Posts: 1,568
Interesting... Could you post the batch files?


Dave Baer
Professor of Digital Arts
Digital Media Arts College
Boca Raton, Florida
dbaer@dmac.edu
# 4 07-11-2003 , 10:19 PM
Darkware's Avatar
Subscriber
Join Date: Oct 2002
Location: USA
Posts: 1,172
Here's how you make your own batch file. It's really simple.

-Open Notepad.
-type:

@ECHO OFF
RD C:\Docume~1\Admini~1\Desktop\Master\TESTMAIN\TESTS UB /s /q
CLS

-File>Save As..... name of file here.bat

The echo command is really unessesary since it happens in the blink of an eye anyway. The RD stands for "remove directory." Then you have the file path which is C:\Docume~1\Admini~1\Desktop\Master\TESTMAIN\TESTS UB The /s removes all directories and files in the specified directory in addition to the directory itself. It is used to remove a directory tree in other words. /q is "quit mode" which is like "no questions asked." It does whatever command you typed before it without asking you "Do you really want to delete this file?"

That's about it though. If you really want to piss someone off, you could do exactly what I described above, only have it delete another more important file on a computer. I don't know if it would do it or not while a user is actually running Windows, but you could have it delete the actual windows file for instance. What's more is that you can stick this on a CD with an autorun file. You can have the autorun file automatically execute the batch (.bat) file and "poof!" the files are deleted just as soon an the computer spins the CD up. You can add asteriks to your file paths to add some varience to your collection of files to delete if you like as well.

But ummm *cough* you shouldn't be doing stuff like this anyway, so I'll shut up. Seriously, although doing this with autorun and batch files is a common thing (especially in my tech class at school) you really shouldn't go around doing this to people. Usually, if I were going to do this, it would only be to erase the same files on several computers at school or a workplace that are corrupted from a virus or are no longer needed. This is a very useful thing to know if you're doing stuff like that.


Last edited by Darkware; 07-11-2003 at 10:24 PM.
# 5 08-11-2003 , 06:33 AM
Darkware's Avatar
Subscriber
Join Date: Oct 2002
Location: USA
Posts: 1,172
ok, I'm trying to do something else now, but I doubt it can be done with a batch file.

I want to be able to type out a document, then run a batch file that will change the character "a" to "f", "b" to "x", etcetc for every character to encrypt it. I know you can go into MS Word and do control+h to bring up the "replace" window, but I don't want to have to type everything out each time I want to do this.

So, my question is..... is there some kind of "replace a with b" syntax with a replace command to do what I described above that will go into a batch file?

Thanks in advance.

# 6 08-11-2003 , 08:33 AM
Zyk0tiK's Avatar
Registered User
Join Date: Aug 2003
Posts: 800
hey you dont want to use a deltree or eqquivilent. else it'll delete the whole folder, if you're deleting the temp intarrwebb files then the folder isn't a good thing to delete :|

# 7 08-11-2003 , 03:49 PM
Darkware's Avatar
Subscriber
Join Date: Oct 2002
Location: USA
Posts: 1,172
yeah I know. deltree isn't fn Windows2000 so you have to use RD. RD only romoves the folder contents and the folder itself if you have /s at the end.

# 8 09-11-2003 , 01:58 AM
Zyk0tiK's Avatar
Registered User
Join Date: Aug 2003
Posts: 800
you dont ever wanna remove the folder itself...

# 9 09-11-2003 , 02:02 AM
Darkware's Avatar
Subscriber
Join Date: Oct 2002
Location: USA
Posts: 1,172
unless you're doing what I described earlier with deleting entire files with the directories they're in like Windows. Of course, that's only if you want to really piss someone off.....

But, there are times you will want to delete the actual folder with all its content included.

Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads