我需要一个批处理脚本来随机选择一个文件夹中的 X 个文件并将它们移动到另一个文件夹。如何编写可以执行此操作的 Windows 批处理脚本?
最佳答案
(我假设您的 X 事先已知 - 由以下代码中的变量 $x
表示)。
由于您并不反对 PowerShell 解决方案:
Get-ChildItem SomeFolder | Get-Random -Count $x | Move-Item -Destination SomeOtherFolder
或更短:
gci somefolder | random -c $x | mi -dest someotherfolder
关于random - Windows批处理文件脚本从一个文件夹中选取随机文件并将它们移动到另一个文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5552368/