bash 在使用 --files-from 复制期间使用 rsync 重命名文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1312411/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using rsync to rename files during copying with --files-from?
提问by Mark Richman
Using rsync, how can I rename files when copying with the --files-from argument? I have about 190,000 files, each of which need to be renamed when copying from source to destination. I plan to have the list of files in a text file to pass to the --files-from argument.
使用 rsync,如何在使用 --files-from 参数复制时重命名文件?我有大约 190,000 个文件,每个文件在从源复制到目标时都需要重命名。我计划将文本文件中的文件列表传递给 --files-from 参数。
采纳答案by Aaron Digulla
There is no way to arbitrarily rename files with rsync. All rsync can do is move files to a different directory.
无法使用 rsync 随意重命名文件。rsync 所能做的就是将文件移动到不同的目录。
You must use a second tool either on the sending or receiving side to rename the files.
您必须在发送端或接收端使用第二个工具来重命名文件。
回答by user129070
Not entirely true... you CAN rename files enroute with rsync, but only if you rsync one file at a time, and set the --no-R --no-implied-dirs options, then explicitly set the destination name in the destination path.
不完全正确...您可以使用 rsync 重命名文件,但前提是您一次 rsync 一个文件,并设置 --no-R --no-implied-dirs 选项,然后在目的地路径。
But at that point, you may just want to use some other tool.
但此时,您可能只想使用其他一些工具。
This, for example, would work:
例如,这将起作用:
rsync --no-R --no-implied-dirs
1.2.3.4::module/$FILENAME
/$PATH/$TOFILE/$NEWFILENAME