我有10-20个目录,每个文件夹里面有很多文件。
我想在每个文件夹中的每个文件包中加入一个文件,所以如果我有20个带有2300个文件的文件夹,我想要20个加入的文件。
实施例
INPUT
folder1 - 500 files
folder2 - 340 files
folder3 - 5 files
OUTPUT REQUEST
folder1.txt (500 joined files)
folder2.txt (340 joined files)
folder3.txt (5 joined files)
但是我有很多文件夹,因此我尝试找到 .bat 命令来自动创建此操作。
视频:what i want
答案 0 :(得分:0)
Assuming each of your files is text file with a newline terminator at the end of each final line, then you can use the following:
for %%F in ("folder1" "folder2" "folder3") do >"%%F.txt" type "%%~F\*"
The name of each file will be output to the screen via stderr.
If you want to hide the file names:
for %%F in ("folder1" "folder2" "folder3") do >"%%F.txt" 2>nul type "%%~F\*"
If you want the file names to be included in the text file output:
for %%F in ("folder1" "folder2" "folder3") do >"%%F.txt" 2>&1 type "%%~F\*"
IF you want to process all folders within your current directory, then change the FOR command for any of the commands listed above to look like:
for /D %%F in (*) do ...