Page 1 of 1

Determine remote file -date stamp

Posted: 18 Sep 2011 08:48
by netwerkassist
Part of a batch file I'm creating is refreshing a sql database from a script being called on a different server. I'd like to be able to check if the remote sql backup file is of the current date and not earlier. This will insure I'm restoring the most current backup.

Can anyone advise a method to check this in the batch file? I'd like to have a line where it checks this and if the date of the backfile (fscm_fullback.bk) is current to continue running the balance of the script, and if not abort script.

Appreciate insight/ideas.

Re: Determine remote file -date stamp

Posted: 18 Sep 2011 10:17
by !k

Code: Select all

set "backup=fscm_fullback.bk"

for /f "tokens=1,2" %%a in ('dir "%backup%" ^|findstr /lic:"%backup%"') do (
  set "backupdate=%%a"
  set "backuptime=%%b"
)

if not "%backupdate%"=="%date%" exit /b 1

Re: Determine remote file -date stamp

Posted: 19 Sep 2011 14:33
by netwerkassist
Thanks for the reply. I would want to check for the existence of the file against a remote server that it sits on. The script you wrote looks like it would check the local server that the script is running on?
Would WMIC work for remote file check, any ideas?

Re: Determine remote file -date stamp

Posted: 22 May 2012 05:54
by foxidrive
PSexec from PStools can run scripts on a remote server.

On the other hand if you are using FTP to gather the files then you can check the datestamp on the FTP server.