this post was submitted on 14 Aug 2026
8 points (100.0% liked)

Linux Questions

4158 readers
2 users here now

Linux questions Rules (in addition of the Lemmy.zip rules)

Tips for giving and receiving help

Any rule violations will result in disciplinary actions

founded 3 years ago
MODERATORS
 

Hey all!

Let me go stratight to the point:

I have an audio player in which I want to clone my ~/Music directory when I connect it to my computer. The only relevant thing about it is that it's a barebones filesystem and I cannot run cool stuff like Syncthing on the player (otherwise this question would already have a solution). Right now, my solution is that I connect the player to the computer and manually copy file to and delete files in the player. As you may have guessed, this is an error prone process. In order to solve that, I want to run a single command that clones ~/Music (src) into /path/to/player/Music (dst).

My requirements are:

  • All new files in src MUST be copied into dst.
  • All files no longer present in src MUST be deleted from dst.
  • All files present in both src and dst that have more recent modifications in src MUST be copied and overwritten into dst.

As you can see, my player's filesystem is a strict replica of my main computer's. Now, I know I can write a Python script in an afternoon to do just that, but I want to know if there are any good tools first to do this. I searched the web in hope that rsync would help me here, but the only answers I can find are for buffier cp. It may be that I have a vocabulary problem and I'm not searching for the correct terms.

I'd love to read your ideas! A note about LLMs: I'm not interested at all in any comments about how llm-of-the-week coded this in a moment, I asked fake-chat and here's what it said or whatever. If you are not a human that can be bothered to write an answer, I won't be bothered to read it.

Thank you!

top 19 comments
sorted by: hot top controversial new old
[–] Shadow@lemmy.ca 11 points 3 weeks ago* (last edited 3 weeks ago) (2 children)

Why not rsync? Off the top of my head: rsync -avp --delete src/* dst/

Stop googling and just read the rsync man page

[–] groctel@lemmy.world 6 points 3 weeks ago (1 children)

Stop googling and just read the rsync man page

Fair enough, sometimes you get tunnel vision with a problem.

For what I see the command doing, thanks for the progress flag, it seems to be doing what I need. Reading the manual, it also looks like it's not copying files that have the same size and timestamp in the source and destination, which is also what I wanted, even though I didn't make it explicit. I'll have to take a look to making the command parallel, probably by running it on every subdirectory of ~Music at once.

Thank you for your help!

[–] lime@feddit.nu 6 points 3 weeks ago (1 children)

rsync is made for quickly backing up huge directories over whatever connection. believe me you won't need to script anything or parallelise it. just check the available flags.

[–] groctel@lemmy.world 1 points 3 weeks ago

My issue atm is that the destination filesystem is very slow, so just querying it every file's timestamp add a very significant delay. Since I can treat my ~/Music directory as the source of truth, I am considering writing a program that saves the status of the local filesystem at a point in time and then generates a diffing script when comparing it to a new status so I can use my fast, local computer to run the update checks.

[–] bjoern_tantau@swg-empire.de 4 points 3 weeks ago (1 children)

You probably want an uppercase P.

rsync -avP --delete src/* dst/
[–] Shadow@lemmy.ca 6 points 3 weeks ago (1 children)

Oops, I did actually mean -p but that's included in -a. Years of muscle memory doesn't go away. -P is a good one too though.

[–] bjoern_tantau@swg-empire.de 2 points 3 weeks ago

I always remember alien vs Predator. And the Predator is uppercase because he's more intelligent. And sometimes alien vz Predator if I want compression.

[–] lime@feddit.nu 4 points 3 weeks ago

i agree with shadow, just use rsync.

[–] schipelblorp@sh.itjust.works 2 points 3 weeks ago (1 children)

Don't remember what all everything does but my default to move to my mp3 player is

systemd-inhibit rsync -avh --delete source dest

The systemd-inhibit is to keep it from falling asleep, --delete removes any files present at destination but not at source.

Out of curiosity, how do you organize your file formats? I have a mess of separate FLAC and separate MP3 files. I'll just regularly convert all my FLAC to a mirrored directory of MP3s and copy that onto SD.

It's a pain in the butt though.

I finally almost have 64gb of music the max on my SD card, so it's time to start throwing music into an archive, too.

[–] groctel@lemmy.world 1 points 3 weeks ago (1 children)

I don't save FLAC files, as I don't have that much space (my library is 82GB big with 17629 tracks atm). What I do is that I have a script I wrote to convert all the files to Opus. I still have some old mp3s laying around that I convert or find better sources over time.

As for rsync command, it's taken far longer than I would like to sync all the files. I've gotten an idea about caching the filesystem status for later uses to speed up the process, so I may end up writing a script after all!

[–] schipelblorp@sh.itjust.works 2 points 3 weeks ago (1 children)

You know more than I do, I think, but how would writing the script speed up the file transfer?

The first time you use rsync, it's going to take a long ass time because you are copying EVERY file. But after the first sync, you're just copying changes, so it'll take much less time.

I use fre:ac to convert things pretty trivially, but I suspect you may enjoy writing scripts, to which I say: enjoy!

[–] groctel@lemmy.world 2 points 3 weeks ago (1 children)

I added some context here. The thing is that it still took ages because stating every file is still very slow in my target player, so if I cache the status I can automatically create a script that just performs the required operations and run that.

And yes, I do enjoy writing small utilities :p Thanks!

[–] schipelblorp@sh.itjust.works 1 points 3 weeks ago (1 children)

What's your player?

I used to copy to the SD card, which was faster, but the dongle I bought from Walmart is really garbage and I realized I could plug directly into the player, but it's much slower.

Even then, at a max of 64GB, I don't think it takes more than 90 minutes to do a full transfer.

I'm enjoying my ownership music journey. Definitely the BEST part is going to thrift stores with 5 CDS/$1 and just exploring, rolling the dice. My latest find is some African jazz dude (Mokassa something or other). I don't know why I can't do the same thing on Spotify, but I think something about having the CD art and description physically right there to inform me, and that I literally know NOTHING about the music.

It is sad, though, because algoirthmic exploration would be a powerful thing, but it's counter to the profit motive. Most people aren't explorers, and the fear of having someone stop listening is too great, so all the paid-service algorithms play it WAY too safe, even within a genre it's often "what is most popular with the most people", so you can't deep dive anything. What is the point? Much better off listening to an internet radio with a pen and paper handy to write down what you like.

[–] groctel@lemmy.world 1 points 2 weeks ago (1 children)

It's an Innioasis Y1, which I'm in the process of changing for another player because the filesystem gets stuck buffering many songs (like 1/5 or even more).

We don't have thrift stores here, so I get my recommendations from friends! Algorithmic exploration is one thing I do miss from YouTube. Even though it was still on the safe side it got me to find many great albums. Nowadays I browse wikipedia pages for genres I'm interested in, the /mu/ essential charts (fuck 4chan but wow what a great resource) and conversations with friends and fedi <3

[–] schipelblorp@sh.itjust.works 2 points 2 weeks ago (1 children)

I like Innioasis but ultimately decided against it because the SD card is embedded in it; maybe yours is failing?

Thanks for the charts!

[–] groctel@lemmy.world 1 points 2 weeks ago (1 children)

I actually replaced it! That's why I'm positive that the issue is with the underlying filesystem driver. At the end of the day, it's just running a basic Android KitKat with the Rockbox app on top. What player do you have? I'm considering getting a new one but have no clue what to get yet XD

[–] schipelblorp@sh.itjust.works 1 points 2 weeks ago (1 children)

Fiio Snowsky Echo Mini, purchased direct from Ali Baba. I think it goes up to 256GB SD card. Seems competently done.

[–] groctel@lemmy.world 1 points 2 weeks ago (1 children)

Ahhh! I considered getting that player last year, but it doesn't support the libopus codec, which is basically all my library. I need one that can run rockbox, as I want to be able to use it for my podcasts as well. It looks beautiful though, I would buy it just to contemplate it <3

[–] schipelblorp@sh.itjust.works 1 points 2 weeks ago* (last edited 2 weeks ago)

I'm codec agnostic, though I try to keep everything in FLAC and convert with FRE:AC to MP3s for the media player. I am not cursed with a discerning ear.