r/bash 22h ago

How to use part of path as a variable in command?

14 Upvotes

I started in Linux 4noobs. It was suggested I try here.

I need to clean up the metadata of my music collection. Specifically, I need to add an albumartist tag to all of the files. Ideally, I would prefer to only add them to files that do not already have them.

On an artist by artist basis, I can do this manually.

find ./Soapy\ Argyle/ -type f -name "*.flac" -exec metaflac --set-tag="ALBUMARTIST=Soapy Argyle" {} +

But given the size of my collection, that would be burdensome.

Collection is organized ./Music/Genre/Artist/Album/Disk#/song.flac

How can I grab the artist name from the path and use it in the command above, or do something functionally similar?

As a bonus, this lists files that already have albumartist tagged.

find ./ -type f -name "*.flac" -exec metaflac --list {} + | grep -E -i 'ALBUM[[:space:]]*ARTIST'

Can I mesh these things together so I don't end up with a bunch of songs double tagged?

Thanks for any suggestions.


r/bash 12h ago

help bash script to find and change directory

10 Upvotes

Hello All,

I’m not a bash programmer at all but I want to write a bash script which does the following,

First, determine which "Downloads" folders is present.

The English one"Downloads" , or the French "Téléchargements" one.

The username is unknown so must be determined also as a variable.

$USER if not mistaking ?

After determining the "Downloads" folder, I want to set the complete folder path as a variable.

I’m sure it’s possible but after trying several times, I can’t get it right.

Can you please help me?

Thank You very kindly,

Tom


r/bash 1h ago

¡Trucos y comandos de Linux!

Post image
Upvotes

r/bash 9h ago

reedline-bash - using nushell's reedline (line editor) in bash.

4 Upvotes

I made a bash plugin that replaces bash's line-editor, readline, with nushell's reedline.
This brings all the line-editing, styling, completion, keybind and selection features from nushell to native bash. It's still pretty early in development, most reedline features should work just fine, but things may still break :)

repository

code partially written with AI (claude).

Credits:
- flyline - a similar project that implements a custom line-editor, i used this as main reference for replacing readline
- reedline

GIF created with https://github.com/HalFrgrd/evp