Computing.Net > Forums > Programming > Batch File to Update if File Change

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.

Batch File to Update if File Change

Reply to Message Icon

Name: howser99
Date: September 4, 2008 at 15:19:03 Pacific
OS: XP
CPU/Ram: Core 2
Comment:

Hi All,

Im looking for a way to check if a file has changed, and if so, copy it to a new direftory (sought of like a rudimentry program update). Any help would be more than appeciatred!



Sponsored Link
Ads by Google

Response Number 1
Name: Judago
Date: September 4, 2008 at 22:10:32 Pacific
Reply:

Does the directory your copying it to have a version of the file?

If so you could probably use a batch file, something to the effect of..


fc x:\destination\existingversion.ext x:\update\newverion.ext>nul
if %errorlevel%==1 (copy x:\update\newverion.ext x:\destination\existingversion.ext) else goto otherstuff
echo.y
:otherstuff

This would compare the files and if they are different the old version would be overwritten with the new version.

If you don't have another file to compare against then you might have to go down the slightly more tedious route of using dates. Obviously You will need something to find if the file has changed, a date an old version.....something?


0

Response Number 2
Name: howser99
Date: September 4, 2008 at 23:43:39 Pacific
Reply:

Thanks for that,

What I think Ill do is create two files that are the same, and when I have a update Ill just replace that file. Problem solved!


Thanks for the help.


0

Response Number 3
Name: Mechanix2Go
Date: September 5, 2008 at 03:12:28 Pacific
Reply:

more simply:

xcopy d:\src\my.txt x:\files\ /d


=====================================
If at first you don't succeed, you're about average.

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







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: Batch File to Update if File Change

Batch File to remove files www.computing.net/answers/programming/batch-file-to-remove-files-/16226.html

Batch - list files only (no path) www.computing.net/answers/programming/batch-list-files-only-no-path/17113.html

Batch file to extract certain lines www.computing.net/answers/programming/batch-file-to-extract-certain-lines/17465.html