Naming a file with yesterdays date

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

edsspuck11

Thread Starter
Joined
Oct 28, 2011
Messages
1
I use the following .bat file to rename a *.csv file with todays date. I need to be able to run the batch file and rename the file with yesterdays day. Can you help?

C:\FPOS40\Bin\LVSRPT.exe Autolvs
C:\FPOS40\Bin\MOVRPT.exe items_15min
C:\FPOS40\Bin\ACTRPT.exe Auto_pickup
C:\FPOS40\Bin\PDOUTRPT.exe Paidouts
C:\FPOS40\Bin\MOVRPT.exe all_items
c:\fpos40\bin\VIRPT.exe VoidItemRPT

SET DDMMYY=
SET YEAR=

REM PLACE PATH TO EXECUTABLE HERE
REM ******************************************************************

C:\FPOSRPT\LC\csvfiles



REM THIS PART CREATES THE DATE IN DDMMYY FORMAT
REM ******************************************************************

FOR /F "TOKENS=1-4 DELIMS=/ " %%A IN ("%DATE%") DO SET DD=%%B
FOR /F "TOKENS=1-4 DELIMS=/ " %%A IN ("%DATE%") DO SET MM=%%C
FOR /F "TOKENS=1-4 DELIMS=/ " %%A IN ("%DATE%") DO SET YEAR=%%D

SET YY=%YEAR:~2,4%
SET DDMMYY=%DD%%MM%%YY%


REM THIS PART RENAMES YOUR FILE USING TODAY'S DATE - %DDMMYY%
REM JUST REPLACE "path to file" WITH THE PATH OF THE REPORT EXPORT
REM ******************************************************************

rem REN C:\path to file %DDMMYY%.CSV

REN C:\FPOSRPT\LC\csvfiles\SBR\Create_CSV\sbr.csv ???%DDMMYY%.CSV
REN C:\FPOSRPT\LC\csvfiles\LVS\Create_CSV\lvs.csv ???%DDMMYY%.CSV
REN C:\FPOSRPT\LC\csvfiles\Item_movement\Create_CSV\Items.csv ?????%DDMMYY%.CSV
REN C:\FPOSRPT\LC\csvfiles\DROP\Create_CSV\Drop.csv ????%DDMMYY%.CSV
REN C:\FPOSRPT\LC\csvfiles\Paidouts\Create_CSV\PDO.csv ???%DDMMYY%.CSV
REN C:\FPOSRPT\LC\csvfiles\AllItems\Create_CSV\Allitems.csv ????????%DDMMYY%.CSV
REN C:\FPOSRPT\LC\csvfiles\VOID\Create_CSV\VOID.csv ????%DDMMYY%.CSV
 

Keebellah

Hans
Trusted Advisor
Joined
Mar 27, 2008
Messages
6,639
Maybe this will help you.
I use a vbs cript to set may daily variables, I cleande the script to just create a TODAY and a YESTERDAY

What the vbs script does is create a batch file in the Temp folder name Envars.bat
I also editted the batch file you posted showing you how I did it;


The idea is to create a folder C:\BAT
If this is not possibel then you will have to create the folder wher you want but edit the GetVars.Bat so it points to the vbs script that needs to be there too.

You start your own batch file
call GetVars.Bat
which triggers the vbs script and EnvVar.Bat is run
the variables TODAY and YESTERDAY are available for use

Check YourBatch.bat to see what I did, and don't forget to edit the C:\Bat if it's different

I hope my explanation helps you, else just test it
 

Attachments

Keebellah

Hans
Trusted Advisor
Joined
Mar 27, 2008
Messages
6,639
To make GetVars.Bat more versatile

Code:
@echo off
TITLE = Setting variables  . .
rem EnvVars.bat wordt aangeroepen de de variabelen kunnen gebruikt worden.
rem Om de variabelen te tonen kan EnvShow.bat gebruikt worden
if exist %TEMP%\OK.txt del %TEMP%\OK.txt
if exist %TEMP%\EnvVars.Bat del %TEMP%\EnvVars.bat
[COLOR="Red"]SET ePATH=%CD%[/COLOR]
Wscript %ePATH%\SetVars.vbs
:repeat
if not exist %TEMP%\OK.txt goto repeat
TITLE = Calling variable . . .
CALL %TEMP%\EnvVars.Bat
The red line checks the path Getvars.Bat is in and looks there for Setvars.vbs, this makes it easier to use, just call the <path> getvars.bat and it works
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top