Rename, Move, Run Access .BAT file

Hello,

I am having trouble with my bat file. I am trying to add today's date to a file and then move the previous days file in another folder. Example:
Yesterdays file is in a folder, I want to run a script to move that and then run my access macro. Once that file is complete then rename the file adding today's date to the end of it. Or is there a way to add today's date to the end of the file name in access? Which ever is easier? Below is what I have:

move "G:\CLSINC\Provana Queries\Daily Letters\DantomPrevDay_*.*".xlsx" "G:\CLSINC\Provana Queries\Daily Letters\Older\
"C:\Program Files (x86)\Microsoft Office\Office12\MSACCESS.exe" "E:\CLS Queries\Provana Database.accdb" /x LettersDailyAudit

SETLOCAL ENABLEDELAYEDEXPANSION
@echo off

For /F "tokens=2,3,4 delims=/ " %%A in ('Date /t') do @(
  Set Day=%%A
  Set Month=%%B
  Set Year=%%C
  Set All=%%A%%B!Year:~-2!
)

Copy "G:\CLSINC\Provana Queries\Daily Letters\DantomPrevDay_.xlsx" "DantomPrevDay_!All!.xlsx"
Del "G:\CLSINC\Provana Queries\Daily Letters\DantomPrevDay_.xlsx"
WO2015Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
The normal approach would be using a timestamp in your tables. Then you don't need to backup your database like this. Shadow copy would be enough.

btw, what is the problem with your script?
0
NVITCommented:
Missing " at end?
move "G:\CLSINC\Provana Queries\Daily Letters\DantomPrevDay_*.*".xlsx" "G:\CLSINC\Provana Queries\Daily Letters\Older

Open in new window


should be...

move "G:\CLSINC\Provana Queries\Daily Letters\DantomPrevDay_*.*".xlsx" "G:\CLSINC\Provana Queries\Daily Letters\Older"

Open in new window

1
Bill PrewCommented:
This path looks wrong, were you looking for one file, or many?

"G:\CLSINC\Provana Queries\Daily Letters\DantomPrevDay_*.*".xlsx"

~bp
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

WO2015Author Commented:
ste5an, how do you use the time stamp in the tables?
0
WO2015Author Commented:
Thank you NVIT, I will add that and see if the "move" works.

Bill Prew - the path is correct, I am looking for one file but the naming convention will vary after DantomPrevDay_ because is will have a different date every day.
0
ste5anSenior DeveloperCommented:
By adding a date/time column to the relevant tables.
0
Bill PrewCommented:
Then I think you need to change:

"G:\CLSINC\Provana Queries\Daily Letters\DantomPrevDay_*.*".xlsx"


to:

"G:\CLSINC\Provana Queries\Daily Letters\DantomPrevDay_*.xlsx"


~bp
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
WO2015Author Commented:
ste5an, thank you, I have that. How to I make that field appear now in the export file name?
0
ste5anSenior DeveloperCommented:
There must be a Save or SaveAs call. Or an TransferSpreadsheet.
0
WO2015Author Commented:
I think I am getting close (I think), Iv never heard of this to I am guessing as what to do here, can you please help?  Here is what I have but its not working, I just want todays date in the export file...

My macro runs the query and then I have the TransferSpreadsheet action:
Type: Export
Spreadsheet Type: Excel
Table Name: DantomPrevDay
File Name: "G:\CLSINC\Provana Queries\Daily Letters\DantomPrevDay_"& Format(Date(), "yyyy\_mm\_dd") &".xlsx"
Has Field Names: Yes
Range: BLANK
0
ste5anSenior DeveloperCommented:
What Access version do you use?

E.g. Access 2013

Capture.PNG
0
WO2015Author Commented:
Access 2007, below is what mine looks like.

Screenshot.jpg
0
WO2015Author Commented:
That worked once I edited the File Name, THANK YOU!!
0
WO2015Author Commented:
Do I even need "Todays Date" in the table?
0
ste5anSenior DeveloperCommented:
Not really, when you use the Date() function.
0
WO2015Author Commented:
Everything is working except the "move" the file is not moving its just overwriting. This is my new script:

move "G:\CLSINC\Provana Queries\Daily Letters\DantomPrevDay_*.*".xlsx" "G:\CLSINC\Provana Queries\Daily Letters\Older"
"C:\Program Files (x86)\Microsoft Office\Office12\MSACCESS.exe" "E:\CLS Queries\Provana Database.accdb" /x LettersDailyAudit
0
Bill PrewCommented:
See my prior post http:#a40996228.

~bp
0
WO2015Author Commented:
Bill, I tried both ways, neither moved the file.
0
Bill PrewCommented:
What was displayed when you executed the command, and can you post up the commands you ran as well please.

~bp
0
WO2015Author Commented:
I got it to work after trying a few things. Thank you for everyone's help!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.