有没有办法自动将一个文件复制到另一个位置?

Is there a way to copy one file to another location automatically?

例如,假设我在这个文件中有一个配置,

d:\Users\jonghyun\Documents\configure.txt

而另一个文件夹是这样存在的。

d:\ConfigureViewer\configureView.txt

我想确保每次更改上层文件时,其他文件也会同时更新,相同的文本。

实现这个的自然方法是什么?

不胜感激 - 使用 powershell 命令,cygwin,vscode

如果您有 NTFS 文件系统,您可以创建硬链接:

fsutil hardlink create <destination filename> <source filename>

所以对于你的例子:

fsutil hardlink create d:\ConfigureViewer\configureView.txt d:\Users\jonghyun\Documents\configure.txt

(On windows) 您可以使用 Robocopy(内置于 windows)。
它有 2 个开关可以满足您的要求:

/mon: Monitors the source, and runs again when more than N changes are detected.
/mot: Monitors source, and runs again in M minutes if changes are detected.

这里是 link 到 docs