Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hi,
We are having a daily process which we need to follow and which requires yesterday's date on which we need to work on folders n files. like today is 08072008 than i need to upload my completed files which came yesterday on 08062008.
I have managed to make a batch file so far but I need to enter yesterday's date as i have set the condition as you can see in batch file what i want is to make it automate just i will run the batch file and it will automatically take the yesterday's date and will follow the instructions
batch file:
===================================
@echo off
set Pdate=%date:~4,2%%date:~7,2%%date:~10,4%%1REM SYSTEM VARIABLE XCOPY SWITCH
set copycmd=xcopy /q /s /c /d /e /h /i /r /yREM VARIABLE - SRV1 C DRIVE
set f=\\server1\c$\testLog.logREM VARIABLE - SRV1'S C DRIVE IAlog_in folder
set h=\\server2\c$\testlog_INset /p UN= PLEASE ENTER DATE :-
IF /I %UN% LSS %Pdate% goto MOVING
) ELSE ECHO DATE NOT MATCHING & EXIT
):MOVING
%copycmd% %f% %h% >> c:\%pdate%_.log
==============================so what i have made is like if the entered date is less than todays date than it will do the MOVE or else exit but when i m entering another date which is less than todays date than also its taking move which folders are already there. What i want is just to make it stick to yesterday's date only.
Any Idea... ?
K2™
System/Network Engineer

it would be easier to use languages that supports date arithmetic like that. you can use vbscript. just a suggestion.

By the way, you seem to be misusing the COPYCMD variable. That's a special variable that is used by the COPY and XCOPY commands. You are meant to set it to the default options to be used by COPY and XCOPY, e.g. SET COPYCMD=/Y. You are not meant to set it to the full command line, and you may get errors from COPY or XCOPY if you do.

i didnt know "if exist" supported "else"
oh btw i cant resist... any1 else here that see the humor in "making batchfile 4 yesterday's date" ??? xD
would be cool if you could make dating into a batch script lolol
(sorry, couldn't resist!)

I obviously mised the joke.
But, so far, no luck with date math in BAT.Better try VBS or perl.
=====================================
If at first you don't succeed, you're about average.M2

thanks all... but i think i need to stick with the batch file i created.. hehe
K2™
System/Network Engineer

btw, is that a script that wil be running 24/7? or is it like "run it and stop it"?
cause i could easly make that work if the script runned all the time :p
or if its acceptable that the bat run all the time, i can make it sleep a few hours, then run, then sleep, but that would require that the computer does not restart/program does not get exited (with B2E i could also make it an "invisible" app, so you wouldn't have to look at it all the time)
:-)

hans,
that will not be running 24/7 we just need to run it when we gets a completion email only. but i would like to thank you for the thoughts you provided and brought the help to me.
thanx
K2™
System/Network Engineer

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |