Reputation: 129
So, I'm trying to convert a bunch of OGG files to M4A using a program called Super. Only problem is that this program adds the extension you're trying to convert to after the source extension.
So, if I convert a file named Keyboard.ogg
to an M4A file, it converts it to an M4A, but the resulting file name is Keyboard.ogg.M4A
.
What I want to do is when the conversion finishes, I want to run a command or batch script on every file ending in .ogg.M4A
so that the result is Keyboard.m4a
instead of Keyboard.ogg.M4A
(The file extension should be lower case since a program I am using to develop a video game requires both .ogg
and .m4a
files for exports (since it uses OGG for PC exports and M4A for Mobile exports) and I think it might be case sensitive.)
I have tried the solution here, but when using %%~nf
it only removes the .M4A part (instead of the .ogg.M4A
) and if I were to rename that I'd be back at square 1.
Upvotes: 0
Views: 104
Reputation: 130819
Assuming none of your file names contain any additional dots other than .ogg.M4A
, then all you need is a single REN
command.
ren *.ogg.M4A ??????????????????????????????.m4a
Be sure to use enough ?
to match the longest name in your file set.
See How does the Windows RENAME (REN) command interpret wildcards? for a full explanation of how REN handles wildcards.
Upvotes: 1
Reputation: 80023
@ECHO OFF
SETLOCAL
SET "sourcedir=U:\sourcedir\t w o"
FOR /f "tokens=1*delims=" %%a IN (
'dir /b /a-d "%sourcedir%\*.ogg.M4A" '
) DO (
FOR %%b IN ("%%~na") DO (
ECHO REN "%sourcedir%\%%a" "%%~nb.m4a"
)
)
GOTO :EOF
You would need to change the setting of sourcedir
to suit your circumstances.
The required REN commands are merely ECHO
ed for testing purposes. After you've verified that the commands are correct, change ECHO(REN
to REN
to actually rename the files.
Take the name of each file in the source directory that fits the mask "*.ogg.m4a"
Using the name part of the filenamename, rename using the name part only +the required extension.
Upvotes: 0