Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: [Q] How to re-encode and replace original FLAC files with new ones? (Read 17301 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

[Q] How to re-encode and replace original FLAC files with new ones?

Hi

I have a huge collection with FLAC files. Some time in future I'm thinking of re-encoding it.
The "problem" is; I can't find a smooth way of doing this. Foobar2k has the option to "overwrite original files", but when encoding it fails, because it tries to delete the file before its decoded. (File in use).

Could anyone come up with a way of re-encoding 100's of folders with FLAC ->  automatically remove old files -> replace them with the new ones? Fully automatic/ no manual labor (rename/ copy/ paste etc)
Without loosing tags.

Im on Windows by the way.
Thanks!

[Q] How to re-encode and replace original FLAC files with new ones?

Reply #1
After you have transcoded, you can just right click and delete the old files in Foobar.

[Q] How to re-encode and replace original FLAC files with new ones?

Reply #2
You can simply use FLAC frontend by not specifying an output folder and checking the box delete input files

http://flacfrontend.sourceforge.net/
Music: sounds arranged such that they construct feelings.

[Q] How to re-encode and replace original FLAC files with new ones?

Reply #3
So, do you want to delete the FLACs completely, or just remove them from your Jukebox software and replace them with the lossy version?

I would never permanently delete the FLACs.  Back them up on an external drive and put them in a drawer.  You never know what might happen with compressed music formats in the future.  It's always good to have an uncompressed original you can convert to a lossy format in the future.

 

[Q] How to re-encode and replace original FLAC files with new ones?

Reply #4
I wrote a batch script for converting my files to FLAC, as I became frustrated with the updated version of the FLAC Frontend.

If you just want to do a simple re-compression of your FLAC files, the following will probably do it:

Code: [Select]
@ECHO OFF
TITLE FLAC Recompressor
SET /P _path=Enter folder path:
ECHO.
ECHO The following FLAC files will be recompressed:
FORFILES /P %_path% /M *.flac /S /C "CMD /C ECHO @file"
ECHO.
ECHO Press any key to continue...
PAUSE >NUL
FORFILES /P %_path% /M *.flac /S /C "CMD /C %~sp0flac.exe @path -8 --verify --force"
ECHO.
ECHO Press any key to exit...
PAUSE >NUL
EXIT
Just copy this into Notepad, save it with a .bat extension, and put it into the same location as your current flac.exe executable.

Run the batch file, enter the folder path of the files you wish to re-compress (you can also drag the folder into the prompt), and press Enter.

A list will appear showing you all of the files it will process, including those in any subdirectories. If you want to see the full file path, and not just the file name, change "@file" on line 6 in the batch file to "@path".

Press Enter again and it will proceed to re-compress all of the FLAC files you've asked it to, overwriting the originals. All meta data is (or at least should be) preserved.

[Q] How to re-encode and replace original FLAC files with new ones?

Reply #5
After you have transcoded, you can just right click and delete the old files in Foobar.

I want the new FLAC's to replace the old ones. Directory wise too.

So, do you want to delete the FLACs completely, or just remove them from your Jukebox software and replace them with the lossy version?

I would never permanently delete the FLACs.  Back them up on an external drive and put them in a drawer.  You never know what might happen with compressed music formats in the future.  It's always good to have an uncompressed original you can convert to a lossy format in the future.

No, im doing Flac->Flac


I wrote a batch script for converting my files to FLAC, as I became frustrated with the updated version of the FLAC Frontend.

If you just want to do a simple re-compression of your FLAC files, the following will probably do it:

Code: [Select]
@ECHO OFF
TITLE FLAC Recompressor
SET /P _path=Enter folder path:
ECHO.
ECHO The following FLAC files will be recompressed:
FORFILES /P %_path% /M *.flac /S /C "CMD /C ECHO @file"
ECHO.
ECHO Press any key to continue...
PAUSE >NUL
FORFILES /P %_path% /M *.flac /S /C "CMD /C %~sp0flac.exe @path -8 --verify --force"
ECHO.
ECHO Press any key to exit...
PAUSE >NUL
EXIT
Just copy this into Notepad, save it with a .bat extension, and put it into the same location as your current flac.exe executable.

Run the batch file, enter the folder path of the files you wish to re-compress (you can also drag the folder into the prompt), and press Enter.

A list will appear showing you all of the files it will process, including those in any subdirectories. If you want to see the full file path, and not just the file name, change "@file" on line 6 in the batch file to "@path".

Press Enter again and it will proceed to re-compress all of the FLAC files you've asked it to, overwriting the originals. All meta data is (or at least should be) preserved.

Thanks, will try it

[Q] How to re-encode and replace original FLAC files with new ones?

Reply #6
SNIP

<sorry, please ignore>

[Q] How to re-encode and replace original FLAC files with new ones?

Reply #7
The free version of dBpoweramp will do this (only replace if there are no errors).

[Q] How to re-encode and replace original FLAC files with new ones?

Reply #8
I want the new FLAC's to replace the old ones. Directory wise too.
Unless there's insufficient space to do it, I would always create the new copies in a separate directory as part of the process, then delete the originals, then just move/rename the top directory of the copies to be the same as the old originals.

I would expect that any solution that appears to change+replace files "in place" is really creating a copy, deleting the original, and then re-naming the copy. It will do this on a per-file basis. You can just do it manually on a complete library basis.

I'm quite wary of running any operation across my whole audio collection, and often do thing to a copy, renaming it back to the original location when I know it's worked. Having a current back-up is just as good, as long as it's not an automated backup that will run the instant you've made the changes, obliterating the good backup with a potentially damaged new version before you've even checked it.

Cheers,
David.

[Q] How to re-encode and replace original FLAC files with new ones?

Reply #9
May I ask why you're re-encode your FLACs to FLACs ?

[Q] How to re-encode and replace original FLAC files with new ones?

Reply #10
I actually meant to post a link to reflac.cmd earlier but ended up with a link to something else, reflacer. But here's the link to a nice cmd file which will bring all your older flac files up to a specified version without re-encoding the "good" ones. http://www.hydrogenaud.io/forums/index.php?showtopic=50993

But... maybe reflacer does what you want to do: http://www.hydrogenaud.io/forums/index.php?showtopic=61511


[Q] How to re-encode and replace original FLAC files with new ones?

Reply #11
AudioShell will do it, but like others, I'd suggest keeping a backup anyway in case something goes wrong. This will take every FLAC file under a directory tree, and re-encode in-place. Note that only common metadata (artist, title, album, track #, year, genre, comment, replaygain) is preserved. You'll lose album art (unless its in a separate file of course) and things like composer, copyright etc).

Code: [Select]
Get-ChildItem C:\Path\To\Music -Filter *.flac -Recurse | Get-AudioFile | Export-AudioFile "FLAC" -Replace

[Q] How to re-encode and replace original FLAC files with new ones?

Reply #12
May I ask why you're re-encode your FLACs to FLACs ?

Possibly to make sure they're all compressed to level 8.

I have a conversion preset set up in Foobar, it converts to Leve 8 and adds "~~" to the beginning of every file name. Once conversion is done, delete every file that doesn't have the prefix and use something like MP3tag to remove it from the new files.
I also like to bit-compare the new files before deleting the old ones, i might just be paranoid though.

EDIT: replaygain tags are lost through this method.

[Q] How to re-encode and replace original FLAC files with new ones?

Reply #13
May I ask why you're re-encode your FLACs to FLACs ?

Possibly to make sure they're all compressed to level 8.

I have a conversion preset set up in Foobar, it converts to Leve 8 and adds "~~" to the beginning of every file name. Once conversion is done, delete every file that doesn't have the prefix and use something like MP3tag to remove it from the new files.
I also like to bit-compare the new files before deleting the old ones, i might just be paranoid though.

EDIT: replaygain tags are lost through this method.


Oh, I don't have space problems (yet) so I didn't think of that.

Thanks andrew_berge

[Q] How to re-encode and replace original FLAC files with new ones?

Reply #14
I have a conversion preset set up in Foobar, it converts to Leve 8 and adds "~~" to the beginning of every file name. Once conversion is done, delete every file that doesn't have the prefix and use something like MP3tag to remove it from the new files.
I also like to bit-compare the new files before deleting the old ones, i might just be paranoid though.

EDIT: replaygain tags are lost through this method.


Why is that? Something to do with foobar? I have a script that uses flac.exe to re-encode FLAC files in place and it retains all tags, including ReplayGain tags.

[Q] How to re-encode and replace original FLAC files with new ones?

Reply #15
I always assumed it was because when converting there are many options (output format, DSPs, etc) that will change the waveform, and potentially the volume as well.

[Q] How to re-encode and replace original FLAC files with new ones?

Reply #16
Different flac compression levels always produce identical decoded wav - that is why FLAC is called lossless format :-)

[Q] How to re-encode and replace original FLAC files with new ones?

Reply #17
Different flac compression levels always produce identical decoded wav - that is why FLAC is called lossless format :-)

Simply rec-compressing a FLAC doesn't change it in any way that would invalidate replygain, but any number of other things could also be done during conversion that would.  Rather than try to work it all out, the tags are simply dropped.

[Q] How to re-encode and replace original FLAC files with new ones?

Reply #18
Simply rec-compressing a FLAC doesn't change it in any way that would invalidate replygain, but any number of other things could also be done during conversion that would.  Rather than try to work it all out, the tags are simply dropped.


If that's the case, then I'd immediately cross foobar off the list of tools that can do the job properly.

[Q] How to re-encode and replace original FLAC files with new ones?

Reply #19
If that's the case, then I'd immediately cross foobar off the list of tools that can do the job properly.

Since years people come and ask for a simple way to reencode their collection and always there is foobar suggested.
foobar never really worked for that purpose without doing some afterwork. Even the vintage fontah was doing it right.
Today there are several nice scripts or ozoks new frontend.
Is troll-adiposity coming from feederism?
With 24bit music you can listen to silence much louder!

[Q] How to re-encode and replace original FLAC files with new ones?

Reply #20
Simply rec-compressing a FLAC doesn't change it in any way that would invalidate replygain, but any number of other things could also be done during conversion that would.  Rather than try to work it all out, the tags are simply dropped.


If that's the case, then I'd immediately cross foobar off the list of tools that can do the job properly.

If you want to do it properly, use a command line tool with the correct options.  If you want to do it quickly and without having to think, let a GUI do it for you.

[Q] How to re-encode and replace original FLAC files with new ones?

Reply #21
my lovely windows batch script with multiprocessing (~multithreading). just put it in the music directory, run it, and it will reencode every flac file recursively. you should have flac.exe near you of course.

Code: [Select]
@echo off

set maxinst=%NUMBER_OF_PROCESSORS%
if %maxinst% GEQ 6 (
set /a maxinst-=2
)

echo Maximum instances %maxinst%
echo.

for /r %%A in (*.flac) do (
call :encodefile "%%A"
)

goto exit

:encodefile
timeout /t 1 /nobreak > nul
for /f "tokens=*" %%N in ('tasklist /fi "IMAGENAME eq flac.exe" /fo csv /nh ^| find /c ","') do set ninstances=%%N
echo currently running... %ninstances%
if %ninstances% LSS %maxinst% (
echo run new... %1
start /min flac -8 -f --no-preserve-modtime %1
goto :eof
) else (
goto encodefile
)

:exit

timeout /t 1 /nobreak > nul
for /f "tokens=*" %%N in ('tasklist /fi "IMAGENAME eq flac.exe" /fo csv /nh ^| find /c ","') do set ninstances=%%N
echo currently running... %ninstances%
if %ninstances% NEQ 0 goto exit

pause


it works really good for me and i use it quite often, but please test it on a small bunch of files beforehand just to be sure.