以下是一个编写批处理文件以传输包含特定数字的文件的示例代码:
@echo off
setlocal
set "source_folder=C:\path\to\source\folder"
set "destination_folder=C:\path\to\destination\folder"
set "search_number=123"
for /R "%source_folder%" %%F in (*) do (
set "filename=%%~nxF"
setlocal enabledelayedexpansion
rem 提取文件名中的数字
set "file_number=!filename:%search_number%=!"
rem 如果文件名中包含指定的数字
if not "!file_number!"=="!filename!" (
rem 将文件传输到目标文件夹
copy "%%F" "%destination_folder%"
)
endlocal
)
endlocal
请根据实际情况更改以下变量:
source_folder
:源文件夹的路径,即要搜索的文件所在的文件夹路径。destination_folder
:目标文件夹的路径,即要将包含特定数字的文件传输到的文件夹路径。search_number
:要搜索的数字。请将上述代码保存为批处理文件(.bat),然后运行它即可将包含指定数字的文件从源文件夹传输到目标文件夹。