Congratulations to AcaCandy on her 100,000th post!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen blue screen boot bsod computer connection crash css dell display drive driver drivers email error ethernet excel firefox firefox 3 hard drive internet internet explorer itunes laptop linux malware monitor network networking outlook outlook 2003 outlook 2007 outlook express partition password problem router slow software sound startup trojan usb video virus vista windows windows xp wireless
DOS/PDA/Other
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Operating Systems > DOS/PDA/Other >
Need to create a batch file but I have no clue!


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
powella's Avatar
Member with 77 posts.
 
Join Date: Jan 2006
Location: Australia
Experience: If knowledge is power, I'm powerless...
08-Feb-2006, 08:18 PM #1
Question Need to create a batch file but I have no clue!
Ok, so I need to create a batch file (echo commands not required) that will complete the following tasks:-
1) Copy all MS Word docs from My Documents on C: to a backup folder called Word on D:
2) Copy all MS Excel docs from My Documents on C: to a backup folder called Excel on D:
3) Copy all MS Access files from My Documents on C: to a backup folder called Access on D:
4) Display a message that the backup process was successful.

This batch file also has to allow for long file names and the names of the files copied onto D: must have the same name as the original file names.

I don't know a great deal about creating batch files at all so any help would be greatly appreciated.
StumpedTechy's Avatar
Distinguished Member with 6,142 posts.
 
Join Date: Jul 2004
Location: Central Florida
Experience: Advanced
09-Feb-2006, 09:41 AM #2
Does this batch file have to be single user or multi user? also are you running it on the account that your logged in as or as nother person and do you have admin rights?

Here is what you can do if its just ran as the user itself.

@echo off
xcopy "C:\Documents and Settings\User\My Documents\*.doc" D:\Word /y
xcopy "C:\Documents and Settings\User\My Documents\*.xls" D:\Excel /y
xcopy "C:\Documents and Settings\User\My Documents\*.mdb" D:\Access /y
cls
echo Insert ending message here.
pause

Just change user to your user account your logged on with (if using an NT based system).

This can be one in a variety of ways too you can do it in VB and get a nice windows GUI popup if you wanted.
powella's Avatar
Member with 77 posts.
 
Join Date: Jan 2006
Location: Australia
Experience: If knowledge is power, I'm powerless...
22-Feb-2006, 08:00 PM #3
Single user is fine and it will be running on the account that I'm logged into.

I amended the one you did there and it worked a treat. Thanks!

Can you tell me what the 'x' before 'copy' is for?
StumpedTechy's Avatar
Distinguished Member with 6,142 posts.
 
Join Date: Jul 2004
Location: Central Florida
Experience: Advanced
22-Feb-2006, 11:06 PM #4
There are 2 dos based commands copy and xcopy. Xcopy has alot of functions the standard copy command does not and I tend to use it more than copy alone. You can get other tools like xxcopy but thats not standard and won't be found on many PC's unless its installed manually there.
Alex Ethridge's Avatar
Distinguished Member with 5,361 posts.
 
Join Date: Apr 2000
Location: Birmingham, Alabama USA
Experience: 14 years of hard knocks
25-Feb-2006, 11:04 PM #5
StumpedTechy's batch will work; but, if you have any subfolders inside your My Documents folder, their contents will be ignored. To correct that, add the /S modifier to get contents of subfolders. It would be a good idea to add that modifier whether you presently have subfolders or not. You may add some later and they will then be taken care of automatically.

Also, it wouldn't be a bad idea to use *.* instead of *.doc, *.xls, etc. as this will get all files in the My Documents folder.

Here's the modified batch:

@echo off
xcopy "C:\Documents and Settings\User\My Documents\*.doc" D:\Word /y /s
xcopy "C:\Documents and Settings\User\My Documents\*.xls" D:\Excel /y /s
xcopy "C:\Documents and Settings\User\My Documents\*.mdb" D:\Access /y /s
cls
echo
[Insert ending message here]
pause


Personally, I would remove the cls line as it clears the screen. Removing it may allow you to see any error messages that might be present after the copy process is finished.
StumpedTechy's Avatar
Distinguished Member with 6,142 posts.
 
Join Date: Jul 2004
Location: Central Florida
Experience: Advanced
26-Feb-2006, 08:06 AM #6
Alex I could have written it a ton of ways but I wrote this specifically for what was asked.

see post number 1 -

echo commands not required (hence the CLS), also nothing indicated about sub dirs OR other files.

I too think there are better ways to back things up (and possibly other things I myself would backup) but I did only write the specs requested

The one thing I love about batch scripting... you literally can do things a thousand ways!
Alex Ethridge's Avatar
Distinguished Member with 5,361 posts.
 
Join Date: Apr 2000
Location: Birmingham, Alabama USA
Experience: 14 years of hard knocks
26-Feb-2006, 11:51 AM #7
Posting a variation on your idea should not be taken as an insult. Replies to a question are not limited to one.
StumpedTechy's Avatar
Distinguished Member with 6,142 posts.
 
Join Date: Jul 2004
Location: Central Florida
Experience: Advanced
27-Feb-2006, 05:11 PM #8
Who indicated insult? I'm not sure where you read that but please don't interpret what I wrote to be indcating insult.
Alex Ethridge's Avatar
Distinguished Member with 5,361 posts.
 
Join Date: Apr 2000
Location: Birmingham, Alabama USA
Experience: 14 years of hard knocks
27-Feb-2006, 05:50 PM #9
Quote:
Alex I could have written it a ton of ways but I wrote this specifically for what was asked.

see post number 1 -

echo commands not required (hence the CLS), also nothing indicated about sub dirs OR other files.

I too think there are better ways to back things up (and possibly other things I myself would backup) but I did only write the specs requested

The one thing I love about batch scripting... you literally can do things a thousand ways!
StumpedTechy's Avatar
Distinguished Member with 6,142 posts.
 
Join Date: Jul 2004
Location: Central Florida
Experience: Advanced
27-Feb-2006, 06:06 PM #10
Hrmmm means nothing to me *shrug* not sure what your getting at.
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 01:38 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.