Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch - Rename multiple files to sequential numbers

Tags:

batch-file

I need to rename multiple files at once. Lets say I have a these files:

episode1.mkv
e1.mkv
s01e01.mkv

As you see, the file names have nothing in common.

How can I change the names of all the files to numbers (1.mkv - 2.mkv - 3.mkv ...) using batch.

I want the first file to be renamed to 1.mkv (no letters or spaces or anything else in the name) the second file to be renamed to 2.mkv, and so on.

I've looked around the internet a lot and I still didn't find anything that does exactly this.

TIA

like image 339
Daniel Halabi Avatar asked Aug 05 '26 11:08

Daniel Halabi


1 Answers

Batch file version

@echo off
setlocal ENABLEDELAYEDEXPANSION
set/a fileNum = 1

for %%f in (*.mp4) do (
  ren %%~nf%%~xf !fileNum!%%~xf
  set/a fileNum += 1
)

GUI version

FreeCommander can do this for you.

  • Run FreeComander
  • Navigate to the folder.
  • Select all the files you want to rename.
  • Hit F2

The rename dialogue will appear. To rename all files names to be numeric do this:

FreeCommander rename dialogue Click Rename to make the change.

like image 173
Terry Ebdon Avatar answered Aug 08 '26 08:08

Terry Ebdon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!