SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.

Home / forum / Lounges / Members Lounge / help with batch files. (.bat)
Register FAQ Members List Calendar Mark Forums Read

New Thread
 
Thread Tools
Old 07-11-2003, 01:10 AM   #1
Darkware
Subscriber
 
Darkware's Avatar
 
Join Date: Oct 2002
Location: USA
Posts: 1,172
Thanks: 0
Thanked 4 Times in 4 Posts
Default 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?
__________________
www.Darkware3D.com
Darkware is offline   Reply With Quote
Old 07-11-2003, 01:46 AM   #2
Darkware
Subscriber
 
Darkware's Avatar
 
Join Date: Oct 2002
Location: USA
Posts: 1,172
Thanks: 0
Thanked 4 Times in 4 Posts
Default

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
__________________
www.Darkware3D.com
Darkware is offline   Reply With Quote
Old 07-11-2003, 07:53 AM   #3
dave_baer
Moderator
 
dave_baer's Avatar
 
Join Date: Sep 2002
Location: Plantation, Florida
Posts: 1,568
Thanks: 0
Thanked 12 Times in 9 Posts
Default

Interesting... Could you post the batch files?
__________________
Dave Baer
Professor of Digital Arts
Digital Media Arts College
Boca Raton, Florida
dbaer@dmac.edu
dave_baer is offline   Reply With Quote
Old 07-11-2003, 09:19 PM   #4
Darkware
Subscriber
 
Darkware's Avatar
 
Join Date: Oct 2002
Location: USA
Posts: 1,172
Thanks: 0
Thanked 4 Times in 4 Posts
Default

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.
__________________
www.Darkware3D.com

Last edited by Darkware : 07-11-2003 at 09:24 PM.
Darkware is offline   Reply With Quote
Old 08-11-2003, 05:33 AM   #5
Darkware
Subscriber
 
Darkware's Avatar
 
Join Date: Oct 2002
Location: USA
Posts: 1,172
Thanks: 0
Thanked 4 Times in 4 Posts
Default

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.
__________________
www.Darkware3D.com
Darkware is offline   Reply With Quote
Old 08-11-2003, 07:33 AM   #6
Zyk0tiK
Registered User
 
Zyk0tiK's Avatar
 
Join Date: Aug 2003
Posts: 800
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 :|
Zyk0tiK is offline   Reply With Quote
Old 08-11-2003, 02:49 PM   #7
Darkware
Subscriber
 
Darkware's Avatar
 
Join Date: Oct 2002
Location: USA
Posts: 1,172
Thanks: 0
Thanked 4 Times in 4 Posts
Default

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.
__________________
www.Darkware3D.com
Darkware is offline   Reply With Quote
Old 09-11-2003, 12:58 AM   #8
Zyk0tiK
Registered User
 
Zyk0tiK's Avatar
 
Join Date: Aug 2003
Posts: 800
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you dont ever wanna remove the folder itself...
Zyk0tiK is offline   Reply With Quote
Old 09-11-2003, 01:02 AM   #9
Darkware
Subscriber
 
Darkware's Avatar
 
Join Date: Oct 2002
Location: USA
Posts: 1,172
Thanks: 0
Thanked 4 Times in 4 Posts
Default

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.
__________________
www.Darkware3D.com
Darkware is offline   Reply With Quote
New Thread

« Previous Thread | Next Thread »

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Batch Rending Render Layers Ozgalis Lighting & Rendering 7 07-01-2011 06:04 PM

1 Month

$34

Month-to-month billing
$34/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
 
 

3 months

$87

Billing every 3 months
$29/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $5 per month or $15 in total compared to monthly billing with this package.

12 months

$288

Billing every 12 months
$24/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $10 per month or $120 in total compared to monthly billing with this package.

Your plan will automatically renew. You can cancel at any time via your PayPal account to avoid being charged again.

You can view the FAQ on our video plans here. You can contact us directly here. By clicking one of the buttons above, you agree to our Terms and Privacy Policy.