Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: Windows Server » microsoft.public.windows.server.scripting
Thread: How to compare file dates on a script

HTVi
TV Discussion Newsgroups

How to compare file dates on a script
Paloma 5/8/2007 1:56:02 PM
Hi,

I am trying to run a simple batch that compares the dates of two files (one
is on the server and the other is on the local computer) the conditions are:
if the file on the local Pc is older than the file on the server, delete it
and then copy the new one.
Is the fc command the one I have to use? because it is not working, I don't
know how to compare the dates, Does anyone know how to do it? This is the one
I was trying to use but it is not completed yet.

rem comparison between PCS and test
fc Z:\batch file.bat C:\Batchfile\batch file.bat
if errorlevel 1 goto newer
goto end
:newer
echo The test file is NEWER than the PCS file.
del C:\BatchFile
COPY Z:\*.* C:\BatchFile
goto end
:end
pause


Thanks in advance


Re: How to compare file dates on a script
Tom Lavedas <tglbatch[ at ]cox.net> 5/8/2007 3:56:34 PM
On May 8, 9:56 am, Paloma <Pal...[ at ]discussions.microsoft.com> wrote:
[Quoted Text]
> Hi,
>
> I am trying to run a simple batch that compares the dates of two files (one
> is on the server and the other is on the local computer) the conditions are:
> if the file on the local Pc is older than the file on the server, delete it
> and then copy the new one.
> Is the fc command the one I have to use? because it is not working, I don't
> know how to compare the dates, Does anyone know how to do it? This is the one
> I was trying to use but it is not completed yet.
>
> rem comparison between PCS and test
> fc Z:\batch file.bat C:\Batchfile\batch file.bat
> if errorlevel 1 goto newer
> goto end
> :newer
> echo The test file is NEWER than the PCS file.
> del C:\BatchFile
> COPY Z:\*.* C:\BatchFile
> goto end
> :end
> pause
>
> Thanks in advance

Look at the /D switch for the xcopy utility. It does all of the work
for you.

Type XCOPY /? at a command prompt.

Tom Lavedas

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen