If both orig_folder
and temp
are on the same physical hard drive, renaming (moving) them is essentially instantaneous. That means you could simply do
用 temp 目录的内容来 替换为 orig_folder的内容
先把 orig_folder 重命名为 foo (中间的临时产生的无用的目录)
再把 temp 重命名为 orig_folder
最后再删除 foo (中间的临时产生的无用的目录)
mv orig_folder foo && mv temp orig_folder && rm -rf foo
That will rename orig_folder
to foo
, then rename temp
to orig_folder
and finally delete foo
. On the same filesystem, the two mv
operations will take next to no time (0.004 seconds on my system).
If the source and target directories are not on the same file system, in order to minimize the timethat the files are not available, you would first need to move the source directory to the same filesystem and then rename:
mv /path/to/temp . && mv orig_folder foo && mv temp orig_folder && rm -rf foo