Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Ветеран


Сообщения: 27449
Благодарности: 8088

Профиль | Отправить PM | Цитировать


В пакетных файлах отсутствует такое понятие, как «массив».

Код: Выделить весь код
@echo off
setlocal enableextensions enabledelayedexpansion

set sSourceFolder=C:\Мои проекты\0186
set sNamesFileList=C:\Мои проекты\0186\Names.txt

if exist "%sSourceFolder%\." (
	if exist "%sNamesFileList%" (
		set /a iCount = 0
		
		for /f "usebackq delims=" %%i in ("%sNamesFileList%") do (
			set sNameFileList!iCount!=%%~i
			set /a iCount += 1
		)
		
		set /a iCount = 0
		
		for /f "usebackq delims=" %%i in (
			`2^>nul dir /b /a:d "%sSourceFolder%\*.*"`
		) do (
			if defined sNameFileList!iCount! call ren "%sSourceFolder%\%%~i" "%%~i %%sNameFileList!iCount!%%"
			set /a iCount += 1
		)
	) else (
		echo Can't find name's file list file [%sNamesFileList%].
		exit /b 2
	)
) else (
	echo Can't find source folder [%sSourceFolder%].
	exit /b 1
)

endlocal
exit /b 0
Это сообщение посчитали полезным следующие участники:

Отправлено: 16:24, 20-08-2018 | #2