0

Need to edit the file names of set of video files in a single folder in Windows 7.

Interested in a simple way to do the following modification to set of file names

Replace the "." with the character "x"

eg. 
   original: 04.19 - Lady & Peebles.mp4
   renamed:  04x19 - Lady & Peebles.mp4

What is a suitable way to do this manually using a Batch file?

SS'
  • 819
  • 1
  • 8
  • 18

3 Answers3

2

Try Like this

@echo off
setlocal EnableDelayedExpansion
for /f "delims=" %%a in ('dir /a-d/b *.mp4') do (
    set "$File=%%~na"
    echo ren "%%a" "!$file:.=x!%%~xa"
)

The echo is included so that you can test the output. If it's OK remove it.

unclemeat
  • 5,029
  • 5
  • 28
  • 52
SachaDee
  • 9,245
  • 3
  • 23
  • 33
0
@echo off
Setlocal enabledelayedexpansion

Set "Folder=C:\Folder\*.mp4"

Set "Pattern=."
Set "Replace=x"

FOR %%# IN ("%Folder%") DO (
    SET "File=%%~nx#"
    REN "%%#" "!File:%Pattern%=%Replace%!"
)

SET "Pattern=xmp4"
SET "Replace=.mp4"

FOR %%# IN ("%Folder%") DO (
    SET "File=%%~nx#"
    REN "%%#" "!File:%Pattern%=%Replace%!"
)

PAUSE&EXIT

Source: How to rename file by replacing substring using batch in Windows

Do some research next time please.

Community
  • 1
  • 1
assembly_wizard
  • 2,034
  • 1
  • 17
  • 10
  • @SS' Did you change the `Folder` variable to the correct path? @ThatWeirdo There's no need for the second renaming - instead of `%%~nx#`, you can use `%%~n#` which will get the name of the file without the extension. You can then tack on the extension at the end. Take a look at the answer from @sachadee. – unclemeat Apr 22 '14 at 23:01
0

Have the first dot ALL the files? If so, then this command-line do the desired rename:

for /F "tokens=1-3 delims=." %a in ('dir /B *.mp4') do ren "%a.%b.%c" "%ax%b.%c"

If you insert previous line in a Batch file, then double the percent signs.

Aacini
  • 65,180
  • 12
  • 72
  • 108