简体   繁体   English

复制/移动不同文件夹中同名的多个文件

[英]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.

相关问题 将具有唯一名称的多个文件移动到新文件夹并追加到文件名 - Move multiple files with unique name to new folder and append to file name 将所有文件夹和文件移动到 Linux 目录中具有相同主题名称的文件夹中 - move all the folders and files to the folder with the same subject name in the directory Linux 用于将文件夹名称复制并添加到来自多个子目录的文件的 Shell 脚本 - Shell script to copy and prepend folder name to files from multiple subdirectories 从Linux中包含文件夹名称的多个文件夹复制文件 - Copy files from multiple folders with including folder name in Linux 在查找和移动Bash脚本中包含相同名称的不同文件 - Including different files with the same name in a Find and Move Bash Script 按名称查找文件夹然后复制文件 - Find folder by name then copy files 仅在下面的目录中查找和同名文件,然后复制到其他目录 - Find and files of same name only in directory below and copy to a different directory Shell:如何将多个文件移动到一个目录并以不同的名称压缩该目录? - Shell: How to move multiple files to a directory and zip that directory with different name? 让一个文件夹包含具有相同名称但文件不同的文件 - Have one folder with files that have the same name but different file Linux Bash:将多个不同的文件移动到同一目录 - Linux Bash: Move multiple different files into same directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM