that would be awesome. what do I need to do to get you to do that for me? (the second option)
Main Topics
Browse All TopicsCan somebody tell me how to write a batch file that I can run every day of the week. This batch file needs to automatically backup an Access database to a specified folder depending on the day of week. I will have seven folders (one for every day). Let's say I run the file on Tuesday, I want it to take the access database and copy it to the Tuesday folder. Is this possible?
Thanks.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Nothing, really. I wrote the script for you. The code is listed below. Copy it to a text file, and give it a .VBS extension. Then, at the top, where it says "SOURCE_FILE", set that equal to the full path and file name of the file you want backed up.
Where it says "DEST_PATH", set that to the full path of where you want it copied (without the day of the week on it).
Also, I've assumed the "Monday", "Tuesday", etc., directories already exist. We can change it is it will create them if necessary, but I don't think you need that.
If you schedule this task to run automatically, you may want to remove the last message that tells you it was done. Just put a single quote mark in front of the line that starts "WScript.Echo ..."
Let me know how it works for you...
Dex*
OPTION EXPLICIT
' Declare Constants
CONST SOURCE_FILE = ".\WhoAt.bat"
CONST DEST_PATH = ".\"
' Declare variables
Dim fso, objFile, strDestPath
' Create Objects
Set fso = CreateObject("Scripting.Fi
' Get the source folder
Set objFile = fso.GetFile( SOURCE_FILE )
' Set the destination path
strDestPath = DEST_PATH
If ( Right(strDestPath, 1) <> "\" ) Then
' Make sure it ends in \
strDestPath = strDestPath & "\"
End If
strDestPath = strDestPath & WeekdayName(Weekday(Now())
' Copy/Move the file
objFile.Copy( strDestPath )
' Display the result
WScript.Echo """" & objFile.Path & """ was copied to """ & strDestPath & """"
When I run it I get an error that says Microsoft VBScript compilation error, line 4 char 8. Error: expected statement. Did I do something wrong?
Here is what I put:
OPTION EXPLICIT
' Declare Constants
f:\aladdin\aladdin golf concierge.mdb = ".\WhoAt.bat"
f:\aladdin\backup\ = ".\"
' Declare variables
Dim fso, objFile, strDestPath
' Create Objects
Set fso = CreateObject("Scripting.Fi
' Get the source folder
Set objFile = fso.GetFile( SOURCE_FILE )
' Set the destination path
strDestPath = DEST_PATH
If ( Right(strDestPath, 1) <> "\" ) Then
' Make sure it ends in \
strDestPath = strDestPath & "\"
End If
strDestPath = strDestPath & WeekdayName(Weekday(Now())
' Copy/Move the file
objFile.Copy( strDestPath )
' Display the result
WScript.Echo """" & objFile.Path & """ was copied to """ & strDestPath & """"
No biggie. You just changed the wrong side of the equation. Try this:
OPTION EXPLICIT
' Declare Constants
SOURCE_FILE = "f:\aladdin\aladdin golf concierge.mdb"
DEST_PATH = "f:\aladdin\backup\"
' Declare variables
Dim fso, objFile, strDestPath
' Create Objects
Set fso = CreateObject("Scripting.Fi
' Get the source folder
Set objFile = fso.GetFile( SOURCE_FILE )
' Set the destination path
strDestPath = DEST_PATH
If ( Right(strDestPath, 1) <> "\" ) Then
' Make sure it ends in \
strDestPath = strDestPath & "\"
End If
strDestPath = strDestPath & WeekdayName(Weekday(Now())
' Copy/Move the file
objFile.Copy( strDestPath )
' Display the result
WScript.Echo """" & objFile.Path & """ was copied to """ & strDestPath & """"
Shortened version:
OPTION EXPLICIT
' Declare Constants
SOURCE_FILE = "f:\aladdin\aladdin golf concierge.mdb"
DEST_PATH = "f:\aladdin\backup\"
' Declare variables
Dim fso, objFile
' Create Objects
Set fso = CreateObject("Scripting.Fi
' Get the source folder
Set objFile = fso.GetFile( SOURCE_FILE )
' Copy/Move the file
objFile.Copy( DEST_PATH & WeekdayName(Weekday(Now())
' Display the result
WScript.Echo """" & objFile.Path & """ was copied to """ & strDestPath & """"
I apologize. I was in a rush before... Those 2 lines need to have the word "Const" in front of them. This should work for you:
OPTION EXPLICIT
' Declare Constants
Const SOURCE_FILE = "f:\aladdin\aladdin golf concierge.mdb"
Const DEST_PATH = "f:\aladdin\backup\"
' Declare variables
Dim fso, objFile
' Create Objects
Set fso = CreateObject("Scripting.Fi
' Get the source folder
Set objFile = fso.GetFile( SOURCE_FILE )
' Copy/Move the file
objFile.Copy( DEST_PATH & WeekdayName(Weekday(Now())
' Display the result
WScript.Echo """" & objFile.Path & """ was copied to """ & strDestPath & """"
Business Accounts
Answer for Membership
by: DexstarPosted on 2003-12-19 at 14:56:58ID: 9975609
@jonathansnyder:
> Is this possible?
Sure. You can either right 7 batch files, and schedule the Monday one to run on Monday, the Tuesday one to run on Tuesdays, etc.
Or, I could whip a VBScript that will copy the file to the right folder based on the current day of the week, and then you can schedule that to run everyday.
Do either of those options appeal to you?
Hope That Helps,
Dex*