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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need batch file syntax to check for last format date.

Status
Not open for further replies.
Oct 11, 2002
28
0
0
US
We've been working with this batch file for several weeks now.

The goal: to copy a file to another server daily and delete the file instance on the first server; to rename the file with the current date on the new server; to check against the last formatted date before copy and delete (the file should not copy if the last formatted date does not equal the current date)

What works: copy, rename, and delete works great

What does not work: the file still copies and deletes regardless of whether the last formatted date matches the current date or not. We have tried the XCOPY command and the XXCOPY command.

The following is the latest attempt:

@echo off
for /F "tokens=2,3,4 delims=/ " %%i in ("%date%") do set DateStamp=%%k%%i%%j
for /F "tokens=1,2,3 delims=:. " %%i in ("%time%") do set TimeStamp=%%i%%j%%k
xxcopy C:\Cold_Results\cold#2.dat \\hpfstore\global$\cold\coldin\pathology\ /DA:.
ren \\hpfstore\global$\cold\coldin\pathology\cold#2.dat %DateStamp%%TimeStamp%.dat
del C:\Cold_Results\cold#2.dat


Any thoughts and suggestions would be greatly appreciated.

Thanks,
Devin
 
Try Robocopy - this will probably work for what you are looking to do (Win2000 Resource Kit)

"The Less You Do, The Less Can Go Wrong" :)
 
If commited to writing yourself, I suggest a little vbs, use the DAtePart method to rename your file

strNewFileName = "NewFile_" & DatePart("m", Now) & "-" & DatePart("yyyy",Now)' makes NewFile_7-2004
strDestPath = "x:\Your\Destination\path\"
Set objFSO = CreateObject ("Scripting.FileSystemObject")
objFSO.FileCopy sourcefile, strDestPath & strNewFileName & ".txt"
objFSO.DeleteFile sourcefile
WSCRIPT.Echo "All Done"

try vbs Forum or Microsoft Script Centre @
Regards ACO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top