Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm looking for something that will allow the content of one file to be mirrored to another file on the same system and partition.

For example, when the content of a file, say, originaltext.txt, was changed, the new content of originaltext.txt would also be present in another file, say, copytext.txt.

I've tried searching for what i have described in the title but all the results i got was of backup programs and software for mirroring across different systems or hard drives.

If anyone has knowledge regarding anything that will allow for this kind of functionality, sharing it would be much appreciated.

share|improve this question
    
Use file link: superuser.com/questions/548829/… –  STTR Jul 21 at 16:36
    
possible duplicate of Make a hard link without extra programs in Windows 7 –  and31415 Jul 21 at 17:05

2 Answers 2

up vote 2 down vote accepted

Create a junction point. It would be the exact same file, pointed to from multiple locations.

Execute (under an Administrative command prompt) mklink /H C:\path\to\new\link C:\path\to\old\link. This will link the two files together, in every way. One changes, the other changes, in real time.

The entire mklink command list is available via Technet.

Another method could be to create a symbolic link (symlink). This is a little more involved, but can be accomplished quickly once set up. Via this guide, you can execute (again, as administrator) junction -s c:\path\to\old c:\path\to\new. This will create a symbolic link, which is useful for essentially creating shortcuts to other files.

share|improve this answer
    
mklink works excellent, the two way mirroring proved to be very useful as well. Many thanks. –  Jonas Jul 21 at 16:50
    
mklink /H creates a hard-link. Implemented via junction-point. For the symbolic link, you can also use mklink with no /H. I don't think you have to be admin, but you do have to enable symbolic links. I remember there is a warning about security in the manual about symbolic links, I don't know why: Unix has hard and soft (symbolic) links and it is not a problem. –  richard Jul 21 at 16:55
    
Do soft (symbolic) links work across partitions/disks on MS-Windows? If so, that is there advantage. Another advantage is that hard linking of directories is a very bad idea. However symbolic linking is one way. –  richard Jul 21 at 16:58
    
@richard Yes, as long as it's on the same system (physically speaking), and they're both on NTFS –  Canadian Luke Jul 21 at 17:42
    
@CanadianLuke I would have thought that the target could be anything fat, smb, cifs, cd, though with the drive letters randomly moving about, or conflicting, there would be a problem keeping them working. I don't have a MS-Windows machine to test on, but I did test it on Gnu/Linux, and it works as expected. However you can not put sym-links or hard-links on FAT file-systems on any operating system, as the file-system does not support them. –  richard Jul 22 at 8:58

This answer will not be truly real-time. In order to do that you will need software that can handle Windows events.

Create a scheduled task to run every x minutes (1 minute would be fine if file is small).

Use this as the command:

robocopy.exe c:\source\ C:\target\ originaltext.txt /mir

This will copy that single text file from c:\source to c:\target.

Robocopy also has an option to monitor source, /mon:x, but this simply keeps the application open in a command window.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.