Computing.Net > Forums > Programming > making batchfile 4 yesterday's date

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

making batchfile 4 yesterday's date

Reply to Message Icon

Name: alwaysk2
Date: August 7, 2008 at 07:14:35 Pacific
OS: 2000 Server
CPU/Ram: 8 GHZ
Product: HP
Comment:

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%%1

REM SYSTEM VARIABLE XCOPY SWITCH
set copycmd=xcopy /q /s /c /d /e /h /i /r /y

REM VARIABLE - SRV1 C DRIVE
set f=\\server1\c$\testLog.log

REM VARIABLE - SRV1'S C DRIVE IAlog_in folder
set h=\\server2\c$\testlog_IN

set /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



Sponsored Link
Ads by Google

Response Number 1
Name: ghostdog
Date: August 7, 2008 at 07:56:39 Pacific
Reply:

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


0

Response Number 2
Name: klint
Date: August 7, 2008 at 09:27:46 Pacific
Reply:

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.


0

Response Number 3
Name: Hans Henrik
Date: August 7, 2008 at 11:19:56 Pacific
Reply:

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!)


0

Response Number 4
Name: Mechanix2Go
Date: August 7, 2008 at 12:15:35 Pacific
Reply:

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


0

Response Number 5
Name: alwaysk2
Date: August 7, 2008 at 18:57:43 Pacific
Reply:

thanks all... but i think i need to stick with the batch file i created.. hehe

K2™
System/Network Engineer


0

Related Posts

See More



Response Number 6
Name: Hans Henrik
Date: August 8, 2008 at 02:20:19 Pacific
Reply:

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)
:-)


0

Response Number 7
Name: alwaysk2
Date: August 8, 2008 at 11:33:57 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: making batchfile 4 yesterday's date

yesterday's date www.computing.net/answers/programming/yesterdays-date/6112.html

How to find yesterday's date in C www.computing.net/answers/programming/how-to-find-yesterdays-date-in-c/4421.html

VB.net get previous date www.computing.net/answers/programming/vbnet-get-previous-date/14687.html