
다음 방법을 사용하여 "scholar (1).txt" 파일을 "scholar (25).txt"에서 단일 .txt 파일로 복사하고 싶었습니다. wikiHow: 명령 프롬프트에서 텍스트(.Txt) 파일 병합
for %f in (*.txt) do type "%f" >> output.txt
SU: Windows 명령줄을 사용하여 텍스트 파일을 결합하는 방법이 있나요?
copy *.txt bigfile.txt
또한
type *.js > all.txt
그러나 모든 파일은 순차적으로 복사되지 않습니다.
`C:\..\Documents\New folder>type *.txt >all.txt
scholar (1).txt
scholar (10).txt
scholar (11).txt
scholar (12).txt
scholar (13).txt
scholar (14).txt
scholar (15).txt
scholar (16).txt
scholar (17).txt
scholar (18).txt
scholar (19).txt
scholar (2).txt
scholar (20).txt
scholar (21).txt
scholar (22).txt
scholar (23).txt
scholar (24).txt
scholar (25).txt
scholar (3).txt
scholar (4).txt
scholar (5).txt
scholar (6).txt
scholar (7).txt
scholar (8).txt
scholar (9).txt`
답변1
(for /l %a in (1 1 25) do @type "scholar (%a).txt")>all.txt
배치 파일 내에서 사용하려면 백분율 기호를 두 배로 늘려야 합니다 %
.%%
총 파일 수를 알 수 없지만 파일 이름이 표시된 대로 지정된 경우 이 코드를 사용할 수 있습니다.
@echo off
setlocal enableextensions disabledelayedexpansion
for %%z in ("scholar (*).txt") do for /f "tokens=2 delims=()" %%a in ("%%~nxz") do (
set /a "num=1000000000+%%a"
setlocal enabledelayedexpansion
for %%b in (!num!) do endlocal & set "f[%%b]=%%~fz"
)
(for /f "tokens=1,* delims==" %%a in ('2>nul set f[') do type "%%b") > all.txt
이렇게 하면 적절하게 숫자로 정렬된 파일 목록을 검색할 수 있는 배열이 환경에 생성됩니다.