Reputation: 857
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?
Upvotes: 0
Views: 362
Reputation: 67216
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.
Upvotes: 0
Reputation: 9545
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.
Upvotes: 2
Reputation: 2064
@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.
Upvotes: 0