Цитата Arsenik77:
В корне файлы переименовываются дописывается "(1)" при повторном запуске батника. »
|
Код:
![Выделить весь код](images/misc/selectcode.png)
@echo off
setlocal
set "exclude=.jpg .mp3 .txt"
for /d %%i in ("generalfolder\*") do (
pushd "%%i"
for /f "tokens=*" %%j in ('dir /b /s /a-d') do call:move "%%j"
popd
)
goto:eof
:move
for %%i in (cnt file check) do set "%%i="
for %%i in (%exclude%) do if /i "%%i"=="%~x1" set check=1
if not defined check del /a /q /f %1 && goto:eof
if "%~dp1"=="%cd%\" goto:eof
set "file=%~nx1"
:check
set /a cnt+=1
if exist "%file%" set "file=%~n1(%cnt%)%~x1" && goto:check
1>nul move %1 "%file%"