这是你想做的吗?:
@Echo OFF
:: By Elektro H@cker
Set "folder=C:\Users\Administrador\Desktop\Test"
Echo Selected Folder: "%FOLDER%"
Set /P "files=Select files to merge (Example: "File1.txt" "File2.txt" "File3.txt") >> "
For %%@ in (%files%) Do (
For /R "%FOLDER%" %%# in (*) DO (
IF /I "%%@" EQU "%%~nx#" (call Set "Files_to_merge=%%Files_to_merge%% "%%#"+")
)
)
)
Copy /A %Files_to_merge:~0,-1% ".\output_file.txt"
pause&Exit
PS:记得更改Copy命令的格式,/A为文本文件,/B为二进制文件。
命令输出:
>Selected Folder: "C:\Users\Administrador\Desktop\Test"
>Select files to merge (Example: "File1.txt" "File2.txt" "File3.txt") >>
>file1.txt file2.txt file3.txt
C:\Users\Administrador\Desktop\Test\file1.txt
C:\Users\Administrador\Desktop\Test\Nueva carpeta\file1.txt
C:\Users\Administrador\Desktop\Test\file2.txt
C:\Users\Administrador\Desktop\Test\Nueva carpeta\file2.txt
C:\Users\Administrador\Desktop\Test\file3.txt
C:\Users\Administrador\Desktop\Test\Nueva carpeta\file3.txt
1 file(s) copied(s).
Presione una tecla para continuar . . .
Output_file.txt 内容:
Content of "File1.txt" in first dir
Content of "File1.txt" in firstsub-dir
Content of "File2.txt" in first dir
Content of "File2.txt" in firstsub-dir
Content of "File3.txt" in first dir
Content of "File3.txt" in firstsub-dir