.bat rename files name remove first x characters and last x characters
batch-file
Solution
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.
Problem
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 set. Can someone show me how to do that?