Цитата dark-------13:
А для второго примера как необходимо сделать ? »
|
Код:
@echo off
SETLOCAL EnableDelayedExpansion
set $DIR=C:\TEST
chcp 1251>nul
for /r "%$DIR%" %%a in (*.txt) do (set "$CN="& set "$O="
for /f "delims=" %%b in ('findstr/rc:"\<CN=" "%%a"') do set "$b=%%b"& set "$b=$!$b:* CN=CN!"& set "!$b:"=!
for /f "delims=" %%b in ('findstr/rc:"\<O=" "%%a"') do set "$b=%%b"& set "$b=$!$b:* O=O!" & set "!$b:"=!
for /f "delims=," %%b in ("!$CN!") do set "$CN=%%b"
for /f "delims=," %%b in ("!$O!") do set "$O=%%b"
ren "%%a" "!$CN!_!$O!%%~xa">nul 2>&1||(chcp 866>nul& echo/
echo/File name "!$CN!_!$O!%%~xa" is busy^^!&echo/File "%%a" skipped.& chcp 1251>nul
))