本帖最后由 piaosi 于 2019-8-1 09:01 编辑
打开记事本将以下内容复制进去,保存为“*.bat”:
@echo off
setlocal EnableDelayedExpansion
set /p a=分类去重包含子文件则输入“a”再回车,不包含则直接回车!
if !a!==a (
attrib -h -r /s *.*
del /s ~*.*
for /f "delims=" %%i in ('dir /a:d-h /b /s') do (
cd /d "%%i"
for %%j in (*.*) do (
set b=%%~tj
move "%%j" "%~dp0%%~nj_!b:~5,2!!b:~8,2!!b:~11,2!!b:~14,2!%%~xj"
)
cd /d "%~dp0"
rd "%%i"
)
)
for %%i in (*.jp*g *.gif *.png *.bmp) do (
set r=%%~ti
set s=%%~zi
if not exist "照片!r:~0,4!" md "照片!r:~0,4!"
move "%%i" "照片!r:~0,4!\!r:~0,4!!r:~5,2!!r:~8,2!!r:~11,2!!r:~14,2!_!s:~-4!%%~xi"
)
for %%i in (*.mp4 *.dat *.3gp *.wmv *.mkv *.avi) do (
set t=%%~ti
set u=%%~zi
if not exist "视频!t:~0,4!" md "视频!t:~0,4!"
move "%%i" "视频!t:~0,4!\!t:~0,4!!t:~5,2!!t:~8,2!!t:~11,2!!t:~14,2!_!u:~-4!%%~xi"
)
for %%i in (*.doc* *.xls* *.ppt* *.pdf *.dwg *.txt *.cebx *.zip *.rar *.7z) do (
set v=%%~ti
set w=%%~ni
set x=_!v:~5,2!!v:~8,2!!v:~11,2!!v:~14,2!
if not exist "办公!v:~0,4!\办公!v:~2,2!!v:~5,2!" md "办公!v:~0,4!\办公!v:~2,2!!v:~5,2!"
for %%j in (!x!) do move "%%i" "办公!v:~0,4!\办公!v:~2,2!!v:~5,2!\!w:%%j=!%%~xi"
)
exit
|