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?
相关问题
- What is the best way to do a search in a large fil
- Spring Integration - Inbound file endpoint. How to
- Unity - Get Random Color at Spawning
- xcopy include folder
- Batch file if string starts by
相关文章
- What is the correct way to declare and use a FILE
- why 48 bit seed in util Random class?
- Making new files automatically executable?
- Need help generating discrete random numbers from
- Extracting columns from text file using Perl one-l
- How to serialize data into indented json [duplicat
- Creating a custom file like object python suggesti
- How can one batch file get the exit code of anothe
(I'm assuming that your X is known beforehand – represented by the variable
$x
in the following code).Since you weren't adverse to a PowerShell solution:
or shorter:
here is a CMD code, which outputs the random file name (customize it to your needs):
The following Batch code will do it. Note that you will need to launch cmd using the following command line:
to enable delayed environment variable expansion. Note also that it will pick a random number of files from 0 to 32767 - you will probably want to modify this part to fit your requirements!
from Need to create a batch file to select one random file from a folder and copy to another folder