This is literally the first ever batch script I've ever written. I'm trying to iterate through the current folder, find all the .mp3 files and then create a folder for each mp3 file with the same title as the file but without the file extension (then move the file into its respective folder add called ffmpeg to split them into shorter chunks but I haven't gotten to that point yet).
I've found a method here to basically exactly what I need to do. I've also found questions here and here which kinda show how to do the assignment of the of the environment variable to the for loop variable, however its not working for me.
This is my code.
@ECHO OFF
cd C:\test
for %%i in (*.mp3) do (
echo %%i
set episodeName=%%i
set episodeName=!episodeName:~0,-4!
echo !episodeName!
mkdir !episodeName!
)
This is my output.
C:\test>"file splitter.bat"
171 Election.mp3
!episodeName!
172 24 Hours at the Golden Apple.mp3
!episodeName!
A subdirectory or file !episodeName! already exists.
What stoopid obvious mistake am I making?