Windows批处理文件脚本从一个文件夹中找出随机文件并将其移动到另一个文件夹 [英] windows batch file script to pick random files from a folder and move them to another folder
本文介绍了Windows批处理文件脚本从一个文件夹中找出随机文件并将其移动到另一个文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要一个批处理脚本的文件夹中随机选择X个文件,并将其移动到另一个文件夹。我怎样写一个Windows批处理脚本可以做这件事?
I need a batch script to randomly select X number of files in a folder and move them to another folder. How do I write a windows batch script that can do this?
推荐答案
(我假设你的 X 的预先&ndash的知道;再$ P $的变量 $ X
在以下code)。
(I'm assuming that your X is known beforehand – represented by the variable $x
in the following code).
既然你不是不利的一个PowerShell的解决方案:
Since you weren't adverse to a PowerShell solution:
Get-ChildItem SomeFolder | Get-Random -Count $x | Move-Item -Destination SomeOtherFolder
或较短的:
gci somefolder | random -c $x | mi -dest someotherfolder
这篇关于Windows批处理文件脚本从一个文件夹中找出随机文件并将其移动到另一个文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文