@echo off setlocal enabledelayedexpansion

set 'source_folder=C:\source_folder' set 'destination_folder=C:\destination_folder'

set 'file_count=0' for /r "%source_folder%" %%f in (*) do ( set /a file_count+=1 set 'file[!file_count!]=%%f' )

set /a random_index=%random% %% %file_count% + 1 set 'random_file=!file[%random_index%]!'

set 'destination_file=%destination_folder%\new_file_%random%.txt'

copy '!random_file!' '!destination_file!' if exist '!destination_file!' ( del '!random_file!' echo 'File copied and original file deleted.' ) else ( echo 'File copy failed.' )

pause>nul

Batch Script: Randomly Copy and Rename a File from One Folder to Another

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

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