Beets: Add an option to preserve the mtime to all beets functions

Created on 5 May 2019  路  9Comments  路  Source: beetbox/beets

Use case

I have a friend with whom I usually share my newest music files. I usually go through my music folder every few months and copy those newer than a certain date into a shared folder. Now beets sadly changes the timestamps of my files for most actions, so this is not possible anymore.

My only option is to "skip metadata updating" (e.g. beet up -M), but that is not quite the best way to do it, as it disables most of the features that made me choose beets in the first place.

Solution

What I'd like to have is an additional parameter to every action that would change a file's metadata (e.g. "update" and "import") which restores the original timestamp after the action is completed.

needinfo

Most helpful comment

You can use mv with the -c, --copy flag;

$ beet ls "added:2019-05-01.."
Porter Robinson - Worlds - Sad Machine
Porter Robinson - Worlds - Flicker
Porter Robinson - Worlds - Fresh Static Snow
Porter Robinson - Worlds - Natural Light
Porter Robinson - Worlds - Sea of Voices
Porter Robinson - Worlds - Fellow Feeling
Porter Robinson - Worlds - Goodbye to a World
Porter Robinson feat. Breanne D眉ren & Sean Thomas Caskey - Worlds - Years of War
Porter Robinson feat. Imaginary Cities - Worlds - Hear the Bells
Porter Robinson feat. Lemaitre - Worlds - Polygon Dust
Porter Robinson feat. Amy Millan - Worlds - Divinity
Porter Robinson feat. Urban Cone - Worlds - Lionhearted
$ mkdir -p /tmp/recently_added
$ beet mv -c -d /tmp/recently_added "added:2019-05-01.."
Copying 12 items.

All 9 comments

Could the importadded plugin do what you're looking for?

Sadly, not quite.

I have set up the importadded plugin as described:

importadded:
  preserve_mtimes: yes
  preserve_write_mtimes: yes

That fixes the issue that files themselves are (mostly) left untouched, but the containing album (and artist) directories still have updated timestamps because "something was changed in them". Maybe it would be enough to enhance importadded so that it restores the parent folder's timestamp?

Example: My music library folder - much older than my usage of beets, so most of the tags inside are rather dirty - follows this pattern:

F:\musik\<artist>\<album>\<track>. <title>

(Sometimes there is an additional "CD 1/2" subfolder.)

I thought I could clean up my tags, so I enabled the importadded plugin and I started the process:

> beet up

A couple of things were changed (e.g. embedart deleted a couple of JPG files, a misconfiguration from my side duplicated a number of albums with a [xxxx] "unique" suffix et cetera), a few bogus meta tags were purged - and all of this, of course, changed the timestamp of the parent folder to "now", even if all the files in it had preserved their original date. I cancelled the process when I saw that, as it would be too much work for me to try and restore the original timestamps for the folders so we wouldn't have to check the whole nine years of already shared music manually...

I don't know if it is technically possible to keep and restore folder timestamps as well (in my case, every <artist> folder should be kept at its original mtime, no matter what beets changed inside of it), but I would like to see it some day. :-)

I don't know if it is technically possible to keep and restore folder timestamps as well (in my case, every folder should be kept at its original mtime, no matter what beets changed inside of it), but I would like to see it some day. :-)

I'm pretty sure this would be technically possible, but probably a huge effort because I'd assume that mtime would need to be explicitly restored in quite a few places.

However, I believe there's a better option since beets already tracks the date of addition explicitly: Does querying theadded field as described in Date and Date Range Queries solve your usecase?

Not really, as it would require me to change my workflow again (basically, run beet up after every single addition) - and it does not solve the problem that beets would change the dates of already existing music.

I think @wisp3rwind is suggesting ignoring the mtime on files completely, and simply going off the beets added field to find any new songs you have added - this should be correct for your library and does not depend on the mtime of the files. It would require a change in your workflow to use beet ls [mtime query here], but it seems like a more robust solution than depending on filesystem modification date.

Can beet automatically copy the results into a separate folder?

You can use mv with the -c, --copy flag;

$ beet ls "added:2019-05-01.."
Porter Robinson - Worlds - Sad Machine
Porter Robinson - Worlds - Flicker
Porter Robinson - Worlds - Fresh Static Snow
Porter Robinson - Worlds - Natural Light
Porter Robinson - Worlds - Sea of Voices
Porter Robinson - Worlds - Fellow Feeling
Porter Robinson - Worlds - Goodbye to a World
Porter Robinson feat. Breanne D眉ren & Sean Thomas Caskey - Worlds - Years of War
Porter Robinson feat. Imaginary Cities - Worlds - Hear the Bells
Porter Robinson feat. Lemaitre - Worlds - Polygon Dust
Porter Robinson feat. Amy Millan - Worlds - Divinity
Porter Robinson feat. Urban Cone - Worlds - Lionhearted
$ mkdir -p /tmp/recently_added
$ beet mv -c -d /tmp/recently_added "added:2019-05-01.."
Copying 12 items.

Well, ok, that would be a workaround...

Closing, I guess this resolved the issue? feel free to reopen if you still consider this missing functionality in beets.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

myfreeweb picture myfreeweb  路  4Comments

cgtobi picture cgtobi  路  3Comments

vredesbyyrd picture vredesbyyrd  路  4Comments

hashhar picture hashhar  路  3Comments

chayward1 picture chayward1  路  4Comments