Reino
28th August 2013, 23:20
Hi,
@ECHO OFF
SET pathToFFmpeg="D:\Binaries\ffmpeg-20130824-git-88909be.exe"
FOR /F "delims=" %%A IN (%*) DO (
IF NOT EXIST "%%~dpnA.mp3" %pathToFFmpeg% -i "%%A" -vn -c:a libmp3lame -q:a 5 -id3v2_version 3 "%%~dpnA.mp3"
)I've made this batch-script (altered actually (http://ffmpeg.zeranoe.com/forum/viewtopic.php?f=17&t=957)) to drag-and-drop media files onto to be encoded to mp3 with FFmpeg. Now the problem is spaces in files/folder names together with /F "delims=".
Let's say we have "sample1.flac" and "sample2.flac" in "D:\Audio\". Dropping these 2 files on the batch-script without /F "delims=" works just fine, but fails when the 2 flac-files reside in "D:\Audio samples\FLAC samples\" and are named "flac sample1.flac" and "flac sample2.flac", because of the spaces.
That's where /F "delims=" comes in. Dropping 1 file on the batch-script with /F "delims=" works fine, but fails when dropping 2 (or more) flac-files. FFmpeg asks if I want to overwrite the dropped 2 flac-files! :confused: What's going on here?
The weird thing is...
@ECHO OFF
SET pathToFFmpeg="D:\Binaries\ffmpeg-20130824-git-88909be.exe"
:loop
IF "%~1"=="" GOTO end
%pathToFFmpeg% -i %1 -vn -c:a libmp3lame -q:a 5 -id3v2_version 3 "%~dpn1.mp3"
SHIFT
GOTO loop
:end
PAUSE...dropping multiple files on this one, and I end up with perfectly encoded mp3-files.
What does a FOR loop need to produce the same results?
Eventhough I'm stuck with this issue, in the end I wanted to create a batch-script where I could also drop a folder onto, so FFmpeg would encode all the files inside.
I did a lot of searching and eventually landed here (http://stackoverflow.com/questions/10960165/batch-script-drag-and-drop-folder-convert-images-with-imagemagick).
@ECHO OFF
SET pathToFFmpeg="D:\Binaries\ffmpeg-20130824-git-88909be.exe"
FOR /F "delims=" %%A IN (%*) DO (
IF EXIST %%A (
IF EXIST %%A\ (
FOR /F "delims=" %%F IN (%%A\*) DO (
IF NOT EXIST "%%~dpnA.mp3" %pathToFFmpeg% -i "%%~F" -vn -c:a libmp3lame -q:a 5 -id3v2_version 3 "%%~A\%%~dpnF.mp3"
)
) ELSE (
IF NOT EXIST "%%~dpnA.mp3" %pathToFFmpeg% -i "%%~A" -vn -c:a libmp3lame -q:a 5 -id3v2_version 3 "%%~dpnA.mp3"
)
) ELSE (
ECHO Skipping non-existent %%~A
)
)
PAUSE
...but since I'm stuck with the spaces-issue, I don't even know if this is the right approach.
If someone knows how to let the script accept spaces in files/folder names in all situations, please point me in the right direction.
@ECHO OFF
SET pathToFFmpeg="D:\Binaries\ffmpeg-20130824-git-88909be.exe"
FOR /F "delims=" %%A IN (%*) DO (
IF NOT EXIST "%%~dpnA.mp3" %pathToFFmpeg% -i "%%A" -vn -c:a libmp3lame -q:a 5 -id3v2_version 3 "%%~dpnA.mp3"
)I've made this batch-script (altered actually (http://ffmpeg.zeranoe.com/forum/viewtopic.php?f=17&t=957)) to drag-and-drop media files onto to be encoded to mp3 with FFmpeg. Now the problem is spaces in files/folder names together with /F "delims=".
Let's say we have "sample1.flac" and "sample2.flac" in "D:\Audio\". Dropping these 2 files on the batch-script without /F "delims=" works just fine, but fails when the 2 flac-files reside in "D:\Audio samples\FLAC samples\" and are named "flac sample1.flac" and "flac sample2.flac", because of the spaces.
That's where /F "delims=" comes in. Dropping 1 file on the batch-script with /F "delims=" works fine, but fails when dropping 2 (or more) flac-files. FFmpeg asks if I want to overwrite the dropped 2 flac-files! :confused: What's going on here?
The weird thing is...
@ECHO OFF
SET pathToFFmpeg="D:\Binaries\ffmpeg-20130824-git-88909be.exe"
:loop
IF "%~1"=="" GOTO end
%pathToFFmpeg% -i %1 -vn -c:a libmp3lame -q:a 5 -id3v2_version 3 "%~dpn1.mp3"
SHIFT
GOTO loop
:end
PAUSE...dropping multiple files on this one, and I end up with perfectly encoded mp3-files.
What does a FOR loop need to produce the same results?
Eventhough I'm stuck with this issue, in the end I wanted to create a batch-script where I could also drop a folder onto, so FFmpeg would encode all the files inside.
I did a lot of searching and eventually landed here (http://stackoverflow.com/questions/10960165/batch-script-drag-and-drop-folder-convert-images-with-imagemagick).
@ECHO OFF
SET pathToFFmpeg="D:\Binaries\ffmpeg-20130824-git-88909be.exe"
FOR /F "delims=" %%A IN (%*) DO (
IF EXIST %%A (
IF EXIST %%A\ (
FOR /F "delims=" %%F IN (%%A\*) DO (
IF NOT EXIST "%%~dpnA.mp3" %pathToFFmpeg% -i "%%~F" -vn -c:a libmp3lame -q:a 5 -id3v2_version 3 "%%~A\%%~dpnF.mp3"
)
) ELSE (
IF NOT EXIST "%%~dpnA.mp3" %pathToFFmpeg% -i "%%~A" -vn -c:a libmp3lame -q:a 5 -id3v2_version 3 "%%~dpnA.mp3"
)
) ELSE (
ECHO Skipping non-existent %%~A
)
)
PAUSE
...but since I'm stuck with the spaces-issue, I don't even know if this is the right approach.
If someone knows how to let the script accept spaces in files/folder names in all situations, please point me in the right direction.