My site is ad supported.

Update To Newest Copy (Script)

Version 1.1 - Download (Requirements Included) | Download (Script Only)


Searches a target directory and subfolders for all files with a specified name and, using the last modified date, identifies the most recent copy. It then compares the hash signature of the most recent copy to all other files with the same name (within the target directory) and replaces any copies where the hash is different with the most recent copy.

Combine this with a scheduled task to easily keep commonly used files (such as source code libraries) in sync across multiple locations. Think about it as sort of a Dropbox type model for your local computer.

A detailed description is available at my article featured on How-To Geek: IT Geek: How to Keep Files with the Same Name in Sync

The script has the following features:

  • Run for a single file or a list of files
  • Optionally create a backup of files which are to be replaced


  • HashMyFiles.exe


The following command locates all files named "common.vb" within the "C:\Code" folder (and all subfolders) and updates all occurances with the last modified copy:

UpdateToNewestCopy C:\Code common.vb

The following command performs the same search operation as above, but only reports on the last modified copy and files to be updated. No files are actually updated by this command.

UpdateToNewestCopy C:\Code common.vb /V

The following command searches the current user's "Web Site" folder (and all subfolders) located in My Documents for all occurances of "javascript_library.js" and updates them to the latest copy. For each copy which is replaced by this process, a backup of the existing file is made first.

UpdateToNewestCopy "%UserProfile%\Documents\Web Sites" javascript_library.js /B

The following command steps through each file name specified in the "C:\TargetFiles.txt" text file and performs the search and replace operation for each inside of the current user's My Documents folder (and all subfolders).

UpdateToNewestCopy "%UserProfile%\Documents" C:\TargetFiles.txt /L

My site is ad supported.

Help Information (/?)

Locates the most recent copy of a file in a specified folder and updates all
other files with the same name to that copy.
Copyright (c) 2013, Jason Faulkner - All rights reserved.

UpdateToNewestCopy SourceFolder FileName [/L] [/V] [/B]

 SourceFolder  The folder to scan. All subfolders are included as well.
 FileName      Name of the file to search for.
               Behavior of this paramter is modified by the /L switch.
 /L            When specified, the FileName parameter is modified such that
               it is treated as a list of files (one file name per line)
               to search for.
 /V            Verify mode. When this is on, files will only be scanned and
               reported with no operations performed.
 /B            When specified, files to be replaced are backed up in the
               in the same directory with ".prev" extension added.
               When listing mode is on, this setting is ignored.

Version History

Version 1.1

  • Fixed a parsing issue where HashMyFiles may not return the text output in the expected encoding. This would cause the script to not find any matches.