Determine remote file -date stamp

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
netwerkassist
Posts: 7
Joined: 21 Apr 2010 12:03

Determine remote file -date stamp

#1 Post by netwerkassist » 18 Sep 2011 08:48

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.

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: Determine remote file -date stamp

#2 Post by !k » 18 Sep 2011 10:17

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

netwerkassist
Posts: 7
Joined: 21 Apr 2010 12:03

Re: Determine remote file -date stamp

#3 Post by netwerkassist » 19 Sep 2011 14:33

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?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Determine remote file -date stamp

#4 Post by foxidrive » 22 May 2012 05:54

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.

Post Reply