2

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

Daniel Halabi
  • 53
  • 1
  • 1
  • 5
  • As a member for almost four years you should already know that this site is not a free code/script writing service, so I guess it is time for you to (re-)take the [tour]… – aschipfl Jul 30 '20 at 07:55

2 Answers2

9

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.

Terry Ebdon
  • 487
  • 2
  • 6
  • This seems to be good. However, I'm looking for a batch script that does this job. I'm trying to create a program that renames all the files to a numerical sequence, and then creates multiple folders, and then moves each renamed file into a specific folder. That's why I can't use any external apps, all should be in 1 batch file. The folder creation part is easy, and I've done it before; the moving files into folders part shouldn't be that hard, but the renaming the files part is the one giving me a hard time. Any help is appreciated, TIA. – Daniel Halabi Jul 29 '20 at 20:41
  • I've updated the answer with a version that will work in a batch file. – Terry Ebdon Jul 29 '20 at 22:28
  • The batch file is very useful! – Sander Bouwhuis Jul 16 '23 at 12:18
0

I suppose you could make a FOR /L loop with a limit of the amount of files in your directory, feed it a DIR /B |FINDSTR .mkv line by line renaming each file to an index variable you keep. Since you are going to name them into just numbers your DIR command will spit the same movie back as the first item over and over so maybe write the output of DIR /B|FINDSTR .mkv to a text file and work off of that? Or move the file you rename to another folder?

Once you make a rough project we could help you refine it? Or use FreeCommander and make a batch to do the rest you want to do after that.

Alfredo
  • 54
  • 7