[英]copy/move same name multiple files in different folder
I have multiple files in different folders with the same name and extension.我在不同文件夹中有多个具有相同名称和扩展名的文件。 For example: There are 460 folders and each folder has one file with the name of snps.vcf.
例如:有 460 个文件夹,每个文件夹有一个名为 snps.vcf 的文件。 I want to copy/move these files to one folder and later on, I will do some analysis that I need to do.
我想将这些文件复制/移动到一个文件夹中,稍后我会做一些我需要做的分析。
I have tried:我努力了:
find -type f -name "*.vcf" -exec cp {} /home/AWAN/try';'
but this code overwrites the files and only one file remains there in the end.但是这段代码会覆盖文件,最后只剩下一个文件。
I have tried rename but I don't know how to select multiple files by find command then rename.我试过重命名,但我不知道如何通过 find 命令重命名 select 多个文件。 Even with the mmv I couldn't find the possible solution.
即使使用 mmv,我也找不到可能的解决方案。
You need to write an external script and pass it to -exec
.您需要编写一个外部脚本并将其传递给
-exec
。 Your script may use mktemp to generate a random file name.您的脚本可能使用mktemp生成随机文件名。 Example:
例子:
mktemp /your/directory/try-XXX
The XXX part will be replaced by mktemp with a different value for each call. XXX 部分将被 mktemp 替换,每次调用具有不同的值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.