Check fileversions

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
garf
Posts: 3
Joined: 21 Jan 2013 08:37

Check fileversions

#1 Post by garf » 21 Jan 2013 09:02

Hi,

I'm new to this forum and need your help.
I have a server with packages that I have to install on new computers. Because I can't always use the link to the server I've put some packages on my USB-drive to install locally (which is faster). What I want to do is make a bat-file that checks if a new version of the file is available on the server and copies it to my pendrive.
This is what I've got so far, but once again I'm not a doswizard :D

Code: Select all

@echo off
set FL=(test1.pkg test2.pkg test3.pkg test4.pkg test5.pkg)
set flag=
for /f "skip=3 tokens=1-3,*" %%a IN ('dir *.pkg /a-d /tc') do (
if /i "%%d"=="bytes" set flag=1
if not defined flag if not "%%d"=="" (
echo Filename: %%d
echo cdate: %%a
echo ctime: %%b
echo size: %%c
echo.
)
)


The problem is I don't know how to easily compare only the files in FL with the files on the server, let's say on location \\10.134.146.3\dis\in_tray
Maybe a 2 dimentional array that stores cdate, ctime, size and compares it in another for-loop when getting the data from there?
How can I nest my FL in the existing for-loop?

Note there are only 5 packages in the FL but normally it's a lot more.

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Check fileversions

#2 Post by abc0502 » 21 Jan 2013 09:27

Just to understand what you need exactly,
you want the batch to connect to the server and then compare all the packages in there with the packages in your Pendrive, and update the packages in your pendrive with the new ones.

where is your server, in the same network ( connect to it using the net use command ), or a FTP server ?

Edit:
Is it possible that in any case your pendrive might have the update package not the server ?

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

Re: Check fileversions

#3 Post by foxidrive » 21 Jan 2013 10:43

If you simply compare the file times then you can copy if they are different.

If they are the same then there's no update needed but if they differ then the package has changed. So update it.

Post Reply