I need to rename files in some folder, like explained it needs to rename file names in one folder by removing first number of x characters and last number of x characters I
Here you go:
@echo off
setlocal enabledelayedexpansion
set X=3
set FOLDER_PATH=.
pushd %FOLDER_PATH%
for %%f in (*) do if %%f neq %~nx0 (
set "filename=%%~nf"
set "filename=!filename:~%X%,-%X%!"
ren "%%f" "!filename!%%~xf"
)
popd
This script enters the folder (specified by FOLDER_PATH
) and trims the first and last X
characters from the filename of each file (leaving its extension as is). Modify X
and FOLDER_PATH
as necessary.