See if you can find any files with an ! in the name, in your output file
You are right ... all the files with and ! in them are missing.
GAHH#$#@&%(^!=!+!";
Now that I've been running my mp3 script for almost 2 days now, it is just about finished.
And all of it useless!
I did put the delayed expansion thingy where you suggested, but then as you can see in my script below I added the variable "fi" to count the number of lines in the temp file so I could periodically dump it and clear it out. I couldn't get the damn variable to increment until I moved the delayed expansion outside the loop. I'm sure there is a way to get it to work, but I just don't understand that fine point well enough yet.
If you post the code you are using then I will test it here on a large number of files - I'm interested to see what is making it slow down once it's running, and if there's a workaround.
Ok, if you are a glutton for punishment, feel free to look at my code which is included below. This version only writes 100 lines to the tempC file before dumping it into the tempB file, then it clears out the tempC file and continues. I see no reason why it should slow down as the tempB file gets bigger. Yes the copy would take a bit longer once the file gets bigger, but the thing is it doesn't really have to do that many copies, and mysteriously the time between lines echoing to the console slows down tremendously as the file gets bigger. And I'm not talking a mere factor of 2 or 5. I'm talking about a factor of 20 times slower or more! What the hell?
Code: Select all
@echo off
set "ffprobe=c:\Util\ffprobe.exe"
set "tempA=%temp%\mp3tmpA.txt" & set "tempbat=%temp%\mp3tmpC"
set "tempB=%temp%\mp3tmpB.txt" & set "tempC=%tempbat%.bat"
type NUL > "%tempB%"
setlocal enabledelayedexpansion
set /a fi=0
for /R %%G IN (*.mp3) do (
rem echo %%G 1>&2
set "fname=%%~pG%%~nG" & set sz=%%~zG
"%ffprobe%" -i "%%G" >"%tempA%" 2>&1
for /f %%a in ('sed -n -r "s_.*Duration: (..:..:..).*_\1_p" "%tempA%"') do (
for /f %%b in ('sed -n -r "0,/Audio: mp3/{s_.*Audio: mp3.*(...) kb.s_\1_p}" "%tempA%"') do (
set "rate= %%b" & set sz=!sz:~0,-4! & set /A sz = !sz! + 5 & set "sz= !sz:~0,-2!.!sz:~-2,-1!"
set "line=%%a !rate:~-3!K!sz:~-6! MB --- !fname!"
if !fi! EQU 100 copy "%tempB%"+"%tempC%" "%tempB%" /B > NUL & type NUL > "%tempC%" & set /a fi=0
set /a fi+=1 & echo !line! & echo !line! >> "%tempC%"
)))
endlocal
copy "%tempB%"+"%tempC%" "%tempB%" /B > NUL
:LoopStart
rem - Extract column 31 and remove duplicate lines
sed -r "s_.{30}(.).*_\1_" %tempB% | sed "$!N; /^\(.*\)\n\1$/!P; D" > "%tempA%"
call :filesize "%tempA%"
if %size% GTR 4 goto LoopDone
rem - Remove column 31 if it is always the same character
sed -r "s_(.{30}).(.*)_\1\2_" %tempB% > %tempA%
copy "%tempA%" "%tempB%" > NUL
goto LoopStart
:filesize
set size=%~z1
goto :eof
:LoopDone
sort /+31 "%tempB%" > mp3time.txt
set sec=0 & set fi=0
sed -r "s_0(.):(.)(.):(.)(.).*_set /A fi+=1 \& set /A sec+=\1*3600+\2*600+\3*60+\4*10+\5_" mp3time.txt > "%tempC%"
call "%tempbat%"
set /A min = sec/60 & set /A sec += 100 - 60*min
set /A hour = min/60 & set /A min += 100 - 60*hour
rem - Append the running time and file count to the end of the results file
set "line===================== Total run time is %hour%:%min:~1%:%sec:~1% (%fi% mp3 files)"
echo %line% & echo %line% >> mp3time.txt
del "%temp%\mp3tmp*.*" > NUL