# ReplayGain - FLAC

**URL:** <https://dietpi.com/forum/t/replaygain-flac/24543>\
**Category:** General Discussion\
**Created:** [16 October 2025 17:00 UTC](https://dietpi.com/forum/t/replaygain-flac/24543 "2025-10-16T17:00:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![TRHH](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/t/ecb155/32.png) [@TRHH](https://dietpi.com/forum/u/TRHH)\
**Post date:** [16 October 2025 17:00 UTC](https://dietpi.com/forum/t/replaygain-flac/24543/1 "2025-10-16T17:00:10Z")

</div>

I am looking for a solution that will add ReplayGain to all my FLAC music files.

I uses Samba (Samba Server - 96):

```auto
\\192.168.xxx.yy\dietpi\Music

```

Thanks for any help

Torben

---

<div class="post-metadata">

**Author:** ![Jappe](https://dietpi.com/forum/user_avatar/dietpi.com/jappe/32/1788_2.png) [@Jappe](https://dietpi.com/forum/u/Jappe)\
**Post date:** [16 October 2025 17:47 UTC](https://dietpi.com/forum/t/replaygain-flac/24543/2 "2025-10-16T17:47:11Z")

</div>

On windows I use [foobar2000](https://www.foobar2000.org). It has a built-in ReplayGain scanner, which can handle FLAC files.

For CLI on your SBC you could use [`metaflac`](https://xiph.org/flac/documentation_tools_metaflac.html), it comes with the [`flac` package](https://packages.debian.org/trixie/flac).

```auto
apt install flac

```

Or if you want more control:  
[https://github.com/Moonbase59/loudgain](https://github.com/Moonbase59/loudgain)

---

<div class="post-metadata">

**Author:** ![TRHH](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/t/ecb155/32.png) [@TRHH](https://dietpi.com/forum/u/TRHH)\
**Post date:** [17 October 2025 04:58 UTC](https://dietpi.com/forum/t/replaygain-flac/24543/3 "2025-10-17T04:58:04Z")

</div>

Thanks @Jappe

If I want to add ReplayGain to the “Music” dir what would be the right command. This:

```auto
#!/bin/bash
MUSIC=/dietpi/Music
 mnt/dietpi_userdata/Music
find $MUSIC -type f -name "*.flac" -exec metaflac --add-replay-gain {} \;

```

or

```auto
#!/bin/bash
MUSIC=/mnt/dietpi_userdata/Music
find $MUSIC -type f -name "*.flac" -exec metaflac --add-replay-gain {} \;

```

And if I want to remove ReplayGain again what would be the right command?

Thanks - Have a great WE

Torben

---

<div class="post-metadata">

**Author:** ![Jappe](https://dietpi.com/forum/user_avatar/dietpi.com/jappe/32/1788_2.png) [@Jappe](https://dietpi.com/forum/u/Jappe)\
**Post date:** [17 October 2025 08:13 UTC](https://dietpi.com/forum/t/replaygain-flac/24543/4 "2025-10-17T08:13:07Z")

</div>

> [@TRHH](#):
>
> And if I want to remove ReplayGain again what would be the right command?

For removal of the ReplayGain tags you can use `--remove-replay-gain`

> [@TRHH](#):
>
> what would be the right command.

The second one, because in the first you have a newline in your file path and also the path differs.  
Also `/dietpi/Music` is not a default path.

* * *

We can optimize this further, to get also filenames with special characters and whitespaces in their name, to skip files which already have a ReplayGain-tag and also run it in parallel, to utilize more then one core:

```bash
#!/bin/bash

MUSIC="/mnt/dietpi_userdata/Music"
find "$MUSIC" -type f -iname "*.flac" -print0 | \
xargs -0 -n1 -P$(nproc) bash -c '
    for file; do
        if ! metaflac --list "$file" | grep -q "REPLAYGAIN_TRACK_GAIN"; then
            echo "Adding ReplayGain: $file"
            metaflac --add-replay-gain "$file"
        else
            echo "Skipping: $file"
        fi
    done
' _

```

`-P$(nproc)` will utilize every core. If you do not want this, you can reduce it like `-P$(( $(nproc) - 1 ))` to “spare” one core. (`$(nproc)` returns the number of your cores)  
Or if you want to say “just use 2” you could also specify `-P2`

---

<div class="post-metadata">

**Author:** ![TRHH](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/t/ecb155/32.png) [@TRHH](https://dietpi.com/forum/u/TRHH)\
**Post date:** [17 October 2025 12:33 UTC](https://dietpi.com/forum/t/replaygain-flac/24543/5 "2025-10-17T12:33:07Z")

</div>

@Jappe - Thanks

Another suggestion:

```auto
#!/bin/bash
MUSIC=/path/to/media/files
shopt -s globstar
for filepath in $MUSIC/**/*.flac; do metaflac --add-replay-gain "$filepath"; done

```

Information as it loops through files and folders:

```auto
folder="${filepath%/*.flac}"
# and so on

```

There seems to be different ways to do this.

Torben

---

<div class="post-metadata">

**Author:** ![Jappe](https://dietpi.com/forum/user_avatar/dietpi.com/jappe/32/1788_2.png) [@Jappe](https://dietpi.com/forum/u/Jappe)\
**Post date:** [17 October 2025 16:27 UTC](https://dietpi.com/forum/t/replaygain-flac/24543/6 "2025-10-17T16:27:00Z")

</div>

Yes, there are different ways. But with your last suggestion it can run into problems for filenames which include special characters or whitespaces. You also get no feedback about progression and possible occuring errors.

My suggestion take of that and also skip files which already have the RepalyGain tag.

---

<div class="post-metadata">

**Author:** ![system](https://dietpi.com/forum/uploads/default/original/1X/7e1021de2213860bce185915ce2c1786e56490ec.png) [@system](https://dietpi.com/forum/u/system)\
**Post date:** [15 January 2026 16:27 UTC](https://dietpi.com/forum/t/replaygain-flac/24543/7 "2026-01-15T16:27:39Z")

</div>

Closed on 15 January 2026 16:27 UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
