파일을 정리하고 싶은 데, 잘 되지 않는 경우가 있다.
@echo off
for %%G in (*.*) do (
call :sub1 "%%G" %%~xG
)
pause
goto :eof
:sub1
Rem ***** whole file name enclose in double quotation
set a1=%1
Rem ***** get extension name like .bat
set a2=%2
Rem ***** take first char which is '.' out
set b=%a2:~1%
Rem ***************************************************
Rem ***** if not this bat file, move it to a folder
Rem ***** for example move a.txt to txt folder
Rem ***** move b.exe to exe folder
Rem ***** move c.mp3 to mp3 folder
Rem ***************************************************
if [%a1%] neq ["%~n0%~x0"] (
if not exist %b% md %b%
move %a1% %b%
)
goto :eof
rem https://green-tree-program.tistory.com/9
파일을 확장명에 따라서 이동하는 Batch File
파일을 정리하고 싶은 데, 잘 되지 않는 경우가 있다. @echo off for %%G in (*.*) do ( call :sub1 "%%G" %%~xG ) pause goto :eof :sub1 Rem ***** whole file name enclose in doub..
green-tree-program.tistory.com
'Batch file' 카테고리의 다른 글
| DOS 에디터 EDLIN 사용법 (0) | 2020.12.31 |
|---|---|
| Batch 파일을 이용하여 path 프린트하기 (0) | 2020.12.30 |
| Batch file을 이용하여 주어진 텍스트 출력하기 (0) | 2020.12.21 |
| Batch 파일을 이용하여 메모 작성하기 (0) | 2020.12.21 |
| 열려진 폴더를 한꺼번에 닫아주는 VBS 프로그램 (0) | 2020.12.02 |
댓글