середа, 20 грудня 2017 р.

Batch script for removing extra symbols after extension

I try to develope my English skills that is why I going to write articles on English. Please enjoy :) 

Script which I have been using for deleting extra right's symbols after extension or other lookup string:

@echo off
setlocal EnableDelayedExpansion

set /p pth=Please input the path to the folder:
set /p ext=Please input the extension:
set replace=

for %%a in ("%pth%\*") do (
set fpath=%%~dpa

set fileVariable=%%~nxa
REM echo.!fileVariable!

CALL SET delPart=%%fileVariable:*%ext%=%%
REM echo.!delPart!

IF defined delPart (
CALL set string=%%fileVariable:!delPart!=!replace!%%
REM echo.!string!

IF defined string (
set "fullNameB=!fpath!!fileVariable!"
REM echo !fullNameB!

ren "!fullNameB!" "!string!"
echo "File: !fileVariable! was renamed to !string!"
)
)

)


pause

Немає коментарів:

Дописати коментар