본문 바로가기
컴퓨터 활용(한글, 오피스 등)/기타

윈도우 cmd 파워쉘 powershell

by 3604 2025. 7. 11.
728x90

파일명 100개  만들기

for /L %i in (1,1,100) do echo. > test%i.txt

REM 방법 1: FOR 루프를 사용한 배치 명령어
for /l %i in (1,1,100) do echo. > test%i.txt

REM 방법 2: 원라이너 PowerShell 명령어 (CMD에서 실행)
powershell -command "1..100 | ForEach-Object { New-Item -ItemType File -Name \"test$_.txt\" -Force }"

REM 방법 3: 배치 파일로 저장하여 실행할 경우
@echo off
for /l %%i in (1,1,100) do (
    echo. > test%%i.txt
    echo test%%i.txt 파일이 생성되었습니다.
)
echo 총 100개의 파일이 생성되었습니다.
pause

REM 방법 4: 빈 파일이 아닌 내용이 있는 파일 생성
for /l %i in (1,1,100) do echo 테스트 파일 %i번 > test%i.txt

REM 방법 5: PowerShell에서 직접 실행
REM PowerShell 콘솔에서 실행:
REM 1..100 | ForEach-Object { New-Item -ItemType File -Name "test$_.txt" -Force }

--------------------------------

디렉토리 3수준까지 출력

Get-ChildItem -Recurse -Directory -Depth 3

 

--------------------------------

 디렉토리 3수준까지 CSV 파일로 추출

Get-ChildItem -Recurse -Directory -Depth 3 | Select-Object FullName | Export-Csv Test.csv -NoTypeInformation -Encoding UTF8

출처: https://kutar37.tistory.com/entry/windows-%ED%8F%B4%EB%8D%94-%ED%8A%B8%EB%A6%AC%EA%B5%AC%EC%A1%B0-%EC%97%91%EC%85%80%EB%A1%9C-%EC%B6%94%EC%B6%9C%ED%95%98%EA%B8%B0

 

 

728x90