以下存为xxx.cmd放在那含有100个文件的文件夹中运行
========================================
@echo off & color 3f
setlocal EnableDelayedExpansion
for /l %%a in (0,1,9) do (
for /l %%b in (0,1,9) do (
for /l %%c in (0,1,9) do (
if %%a%%b%%c EQU 001 set D=A
if %%a%%b%%c EQU 021 set D=B
if %%a%%b%%c EQU 041 set D=C
if %%a%%b%%c EQU 061 set D=D
if %%a%%b%%c EQU 081 set D=E
if %%a%%b%%c EQU 101 exit
if not exist ".\!D!" md "!D!"
if exist "%%a%%b%%c.txt" move /y "%%a%%b%%c.txt" ".\!D!"
)
)
)
endlocal & exit
========================================
@echo off&color a&setlocal enabledelayedexpansion
Set str=000
For /f "delims=" %%a In ('dir /a-d /b') do (
if not %%~a==%~nx0 (
Set /a n+=1
Set filename=%str%!n!
ren "%%~a" !filename:~-3!%%~xa
If !n! leq 20 move !filename:~-3!%%~xa a
If !n! geq 21 If !n! leq 40 move !filename:~-3!%%~xa b
If !n! geq 41 If !n! leq 60 move !filename:~-3!%%~xa c
If !n! geq 61 If !n! leq 80 move !filename:~-3!%%~xa d
If !n! geq 81 If !n! leq 100 move !filename:~-3!%%~xa e
)
)
pause
指定文件夹是否在当前目录?
指定文件夹是否有顺序要求?