@echo off setlocal enabledelayedexpansion

set source_path=C:\source_folder set target_path=C:\target_folder

set /a count=0

for /r "%source_path%" %%f in (*) do ( set /a count+=1 set "file=%%f" )

set /a random_num=%random% %% %count% + 1

set /a current_num=0

for /r "%source_path%" %%f in (*) do ( set /a current_num+=1 if !current_num! equ %random_num% ( set "file=%%f" set "file_name=!file:%source_path%=%target_path%!" set "file_name=!file_name:=_!" copy "!file!" "!file_name!" del "!file!" exit /b ) )

用bat脚本写一个遍历文件夹随机复制一个文件到另一个文件夹并重新命名复制完成后删除原文件

原文地址: https://www.cveoy.top/t/topic/b7wg 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录