Good day!
I tried to create a batch file, which in all files in the folder will replace the letter t with the letter s. Here is my code: for /rc:\ %%i in (*t*.*) do ren %%i (*s*.*)
What am I doing wrong?
All wrong. Here's how:
rem ΠΠΊΠ»ΡΡΠ°Π΅ΠΌ ΠΎΡΠ»ΠΎΠΆΠ΅Π½Π½ΠΎΠ΅ ΡΠ°ΡΡΠΈΡΠ΅Π½ΠΈΠ΅ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ
SetLocal EnableDelayedExpansion rem Π¦ΠΈΠΊΠ» ΠΏΠΎ Π²ΡΠ΅ΠΌ ΡΠ°ΠΉΠ»Π°ΠΌ, ΡΠΎΠ΄Π΅ΡΠΆΠ°ΡΠΈΡ
Π² ΠΈΠΌΠ΅Π½Π°Ρ
Π±ΡΠΊΠ²Ρ t (Ρ Π·Π°Ρ
ΠΎΠ΄ΠΎΠΌ Π² ΠΏΠΎΠ΄ΠΊΠ°ΡΠ°Π»ΠΎΠ³ΠΈ) for /rc:\ %%i in (*t*.*) do ( rem ΠΡΠ΄Π΅Π»ΡΠ΅ΠΌ ΠΈΠΌΡ ΡΠ°ΠΉΠ»Π° (Π±Π΅Π· ΠΊΠ°ΡΠ°Π»ΠΎΠ³Π° ΠΈ ΡΠ°ΡΡΠΈΡΠ΅Π½ΠΈΡ). set NEW_NAME=%%~ni rem ΠΠ°ΠΌΠ΅Π½ΡΠ΅ΠΌ Π²ΡΠ΅ Π²Ρ
ΠΎΠΆΠ΄Π΅Π½ΠΈΡ Π±ΡΠΊΠ²Ρ t Π½Π° s. set NEW_NAME=!NEW_NAME:t=s! rem ΠΠ΅ΡΠ΅ΠΈΠΌΠ΅Π½ΠΎΠ²ΡΠ²Π°Π΅ΠΌ ΠΈΡΡ
ΠΎΠ΄Π½ΡΠΉ ΡΠ°ΠΉΠ». ΠΠΎΠ²ΠΎΠ΅ ΠΈΠΌΡ Π³Π΅Π½Π΅Π½ΡΠΈΡΡΠ΅ΠΌ ΠΈΠ· ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΠΎΠΉ rem !NEW_NAME!, Π΄ΠΎΠ±Π°Π²Π»ΡΡ ΠΊ Π½Π΅ΠΉ ΠΈΡΡ
ΠΎΠ΄Π½ΠΎΠ΅ ΡΠ°ΡΡΠΈΡΠ΅Π½ΠΈΠ΅ (%%~xi). rename "%%i" "!NEW_NAME!%%~xi" ) EndLocal For more information about the applied constructions, see the help output by the following commands:
SetLocal /? set /? for /? Source: https://ru.stackoverflow.com/questions/533265/
All Articles