简体   繁体   English

随机 select 并将 500 个目录/文件夹从一个文件夹移动到另一个?

[英]Randomly select and move 500 directories/folders from a folder to another?

I want to move/copy 500 folders from one directory to another.我想将 500 个文件夹从一个目录移动/复制到另一个目录。 Here, I am not choosing the files randomly but directories/folders.在这里,我不是随机选择文件,而是选择目录/文件夹。

I used the following command to do it, but i am able to mv only a few folders and not 500 folders are moved.我使用以下命令来执行此操作,但我只能移动几个文件夹,而不是移动 500 个文件夹。 Any suggestions on the following command?对以下命令有什么建议吗?

ls | shuf -n 500 | xargs -i mv {} /path-folder/

Use find -type d to select directories, shuf to randomize the order, and head -n 500 to select 500 random directories:使用find -type d到 select 目录, shuf随机排序, head -n 500到 select 500 个随机目录:

find . -mindepth 1 -maxdepth 1 -type d | shuf | head -n 500 | xargs -I{} mv {} dest_dir/

See also find manual for more details.另请参阅find手册了解更多详细信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从各种目录中随机选择一个文件并进行排序 - Select randomly a file from various directories and sort 将多个文件从文件夹移动到目录列表(撤消移动命令) - Move multiple files from a folder to list of directories (Undo a move command) 将日期之前创建的目录移动到另一个目录? - move directories created before a date to another directory? 将特定文件从一个文件夹移动到另一个文件夹的脚本 - Script to move specific files from one folder to another 从第 n 级子文件夹复制或移动到另一个目录或文件夹 - Copy or move from nth level subfolder to another directory or folder 如何在创建环境时将.conda 从一个文件夹移动到另一个文件夹 - How to move .conda from one folder to another at the moment of creating the environment 如何使用find和xargs将文件从一个文件夹中的一个文件夹移动到另一个文件夹? - How do you use find and xargs to move files from a folder within a folder to another folder? Apache将2个文件夹重定向到另一个文件夹或网络共享 - Apache Redirect of 2 folders to another folder or network share 使用相同的文件夹结构移动早于特定时间的文件和目录 - Move files and directories older than specific time with the same folder structure Linux:如何在不登录的情况下将文件从一个文件夹移动到远程计算机中的另一个文件夹 - Linux : How to move a file from one folder to another folder in a remote machine without logging in
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM