Renaming non-ASCII files

Hey all. Have been using Beets for a while and absolutely love it. I have a problem that’s racking my brain.

I have a very well-established collection of music, but only recently noticed that Beets allowed utf-8 characters into filenames, such as á, é, í, ó, ú, ü, ñ and what-not.

The filesystem/server that the music is on and where it is played from is totally fine with this. But, I run into problems when I try to do Beet operations from another computer, as the conversion of those characters means that I can’t read those files, and Beets throws errors. I don’t think this is a bug with Beets, it’s just the way the mounted filesystem works.

Ultimately I just want to rename those files or directories. But, there are 100’s, maybe 1000’s of them.
I know the beet move command exists and works great for other files, but for these it throws errors:

beet move "albumartist_sort::^b"
Moving 44 items.
Error: No such file or directory while moving /Volumes/Multimedia/tunes/albums/****.mp3 to /Volumes/Multimedia/tunes/albums/****.mp3

I’ve tried many, many ways to go about this. I’ve tried different settings on mounting the filesystem, but I really don’t think there’s a way to do that. I’ve tried re-importing those files/albums, but it’s very slow and it can be difficult to match up the right album, and then I still have to manually remove the old files.

Any suggestions are welcome. I’m really kind of lost here.

Hi! Can you give a few more details about the error you’re seeing? That would help give a bit more context.

Sure, here’s the output with -vv:

$ beet -vv move "albumartist_sort::^b"
user configuration: /Users/ap/.config/beets/config.yaml
data directory: /Users/ap/.config/beets
plugin paths: 
Sending event: pluginload
inline: adding item field artist_ranked
inline: adding item field artist_only_ranked
inline: adding item field different_artist
artresizer: method is (2, (7, 0, 10), False)
lyrics: Disabling google source: no API key configured.
library database: /Users/ap/.config/beets/beets.db
library directory: /Volumes/Multimedia/tunes
Sending event: library_opened
Moving 44 items.
moving: /Volumes/Multimedia/tunes/albums/B/bôa/1998 - Duvet/01 - Duvet.mp3
Sending event: before_item_moved
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/beets/util/__init__.py", line 481, in move
os.rename(path, dest)
FileNotFoundError: [Errno 2] No such file or directory: b'/Volumes/Multimedia/tunes/albums/B/bo\xcc\x82a/1998 - Duvet/01 - Duvet.mp3' -> b'/Volumes/Multimedia/tunes/albums/B/boa/1998 - Duvet/01 - Duvet.mp3'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/beets/util/__init__.py", line 485, in move
shutil.copyfile(path, dest)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/shutil.py", line 120, in copyfile
with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: b'/Volumes/Multimedia/tunes/albums/B/bo\xcc\x82a/1998 - Duvet/01 - Duvet.mp3'

Error: No such file or directory while moving /Volumes/Multimedia/tunes/albums/B/bôa/1998 - Duvet/01 - Duvet.mp3 to /Volumes/Multimedia/tunes/albums/B/boa/1998 - Duvet/01 - Duvet.mp3

Specifically, this is the core error:

FileNotFoundError: [Errno 2] No such file or directory: b'/Volumes/Multimedia/tunes/albums/B/bo\xcc\x82a/1998 - Duvet/01 - Duvet.mp3' -> b'/Volumes/Multimedia/tunes/albums/B/boa/1998 - Duvet/01 - Duvet.mp3'

And even more specifically it is escaping the utf-8 characters: /bo\xcc\x82a/ which is really /bôa/ on the original filesystem.

Again, I don’t think this is an error with Beets, but I was hoping someone came across this issue and may have found a way to fix it without a lot of manual steps. My current plan is try to install Beets on my NAS, though I really don’t want to go down that route for many reasons.

Huh, that is pretty weird! Thanks for all the extra details. And to confirm, that file does actually exist, right? The one at this path (when properly “unescaped”)?

b'/Volumes/Multimedia/tunes/albums/B/bo\xcc\x82a/1998 - Duvet/01 - Duvet.mp3'

That is, this command does what you’d expect?

ls '/Volumes/Multimedia/tunes/albums/B/bôa/1998 - Duvet/01 - Duvet.mp3'

My best guess is that something’s wrong with the network filesystem mount. Any chance that can be reconfigured?

Yeah, so trying to list file does throws an error:

ls '/Volumes/Multimedia/tunes/albums/B/bôa/1998 - Duvet/01 - Duvet.mp3'
File not found

But, through lots of research, I don’t think there’s anyway I can mount the filesystem differently. It’s a Mac with a SMB share.

I’ve just decided to use a spare Raspberry Pi I have around and mount the share there and install beet there and do the move. Kind of annoying, but I think it’s the only way.