用bat脚本随机复制文件并重命名且删除原文件
@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
)
)
原文地址: https://www.cveoy.top/t/topic/npsb 著作权归作者所有。请勿转载和采集!