Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rename file to append date (1 day earlier)

Status
Not open for further replies.

thecentz303

IS-IT--Management
Oct 24, 2011
2
US
Good Day everyone,

I am trying to create a batch file that will take a .txt document and rename it, appending the yesterdays date to it. I found after much searching I could use the batch file below to append the current date buy I have not found a way to increment down 1 day.

Any help would be greatly appreciated.


echo on

if not exist E:\accounting\Checks Issued\Checks_Issued_Daily.txt goto END

copy "E:\accounting\Checks Issued\Checks_Issued_Daily.txt" "E:\accounting\Checks Issued\Archive\Checks_Issued_Daily-%date:~4,2%-%date:~7,2%-%date:~12,2%.txt"

:END
 
Rather than using .BAT files look into PowerShell. It can do this pretty easily.

________________________________________
CompTIA A+, Network+, Server+, Security+
MCTS:Windows 7
MCSE:Security 2003
MCITP:Server Administrator
MCITP:Enterprise Administrator
MCITP:Virtualization Administrator 2008 R2
Certified Quest vWorkspace Administrator
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top