INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Trouble renaming/moving files (UTF-8 issue?)  (Read 3361 times)

InflatableMouse

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3978
Trouble renaming/moving files (UTF-8 issue?)
« on: October 21, 2014, 10:38:55 am »

I have several files that MC won't rename or move, while a file manager or from terminal there is no issue.

I tried a few things, and found that for the first 3 files, a particular character was causing it.

This filename did not rename or move:
/mnt/Data/Music Leftover/Joe Satriani/[1995] Joe Satriani/11 - (You`re) My World.flac

After manually renaming and reimporting, it would:
/mnt/Data/Zooi/Music Leftover/Joe Satriani/[1995] Joe Satriani/11 - (You're) My World.flac

The same goes for 2 other files with the same character.

Other files had a $-sign. For instance:
/mnt/Data/Music Leftover/Metallica/[1987] The $5.98 E.P. Garage Days Re-Revisited/02 - So What_.flac

The file would not move because the album title has a $ and the move rule was like [Artist]/[Album]/...

When I removed the $-sign from the tag the file moved perfectly.

Editing the tag alone was not enough; MC will not rename a file if the filename has an "invalid" character, or move if the file or directory has an "invalid" character. Manually removing these characters, reimporting them and then rename/move was the only option.
Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: Trouble renaming/moving files (UTF-8 issue?)
« Reply #1 on: October 21, 2014, 11:16:42 am »

Obviously those (backticks and dollar signs) are both special characters that trigger expansion/evaluation in the shell, so if MC is using the shell to move/rename files that's probably why it's struggling with them.

Out of curiosity does it work if you escape the characters in MC (or does it just automatically convert backslashes to forward slashes)?
Logged

InflatableMouse

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3978
Re: Trouble renaming/moving files (UTF-8 issue?)
« Reply #2 on: October 21, 2014, 11:21:01 am »

I don't think I understand, how would I escape them?

I don't type in a new name, I use a rule for directory [artist]/[album] and for filename [track #] - [name].
Logged

Hendrik

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10943
Re: Trouble renaming/moving files (UTF-8 issue?)
« Reply #3 on: October 21, 2014, 11:27:04 am »

I'll poke at the functions we use to interact with the file system, lets see what I can dig up!
Logged
~ nevcairiel
~ Author of LAV Filters

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: Trouble renaming/moving files (UTF-8 issue?)
« Reply #4 on: October 21, 2014, 11:27:31 am »

I don't think I understand, how would I escape them?

The same way you would escape them in the shell, by\ prefacing\ whitespace\ or\ special\ ch\@racter\$\ with\ preceding\ backslashes.

It probably wouldn't work anyway as MC probably just automatically converts backslashes into forward slashes for linux compatibility (or converts them to string literal backslashes or some other character combo instead of escape characters)

Quote
I don't type in a new name, I use a rule for directory [artist]/[album] and for filename [track #] - [name].

Sorry, then my suggestion wouldn't help anyway, it was just an idea to test if MC is using the shell to move files around or something else.


Logged

Hendrik

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10943
Re: Trouble renaming/moving files (UTF-8 issue?)
« Reply #5 on: October 21, 2014, 11:34:22 am »

Looks like the hunch of the special shell commands was spot on, I'll work on a fix to quote and escape properly.
Logged
~ nevcairiel
~ Author of LAV Filters

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: Trouble renaming/moving files (UTF-8 issue?)
« Reply #6 on: October 21, 2014, 11:48:35 am »

Looks like the hunch of the special shell commands was spot on, I'll work on a fix to quote and escape properly.

Sweet!  It just seemed a little too coincidental that the two characters that trigger command substitution/evaluation were the ones causing problems.

I assume you're thinking of a general purpose solution that would sweep in other shell special characters that might also need to be taken care of? (e.g. pipes, redirection symbols, double quotes, single quotes, equal signs, etc.)  

Or was MC already double quoting everything? Which would take care of everything but (I think):
Code: [Select]
$
`
!
"
\
Logged

InflatableMouse

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3978
Re: Trouble renaming/moving files (UTF-8 issue?)
« Reply #7 on: October 21, 2014, 11:54:36 am »

Thanks Hendrik!
Logged

Hendrik

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10943
Re: Trouble renaming/moving files (UTF-8 issue?)
« Reply #8 on: October 21, 2014, 12:11:40 pm »

Sweet!  It just seemed a little too coincidental that the two characters that trigger command substitution/evaluation were the ones causing problems.

I assume you're thinking of a general purpose solution that would sweep in other shell special characters that might also need to be taken care of? (e.g. pipes, redirection symbols, double quotes, single quotes, equal signs, etc.)  

The general purpose solution is single quoting everything, and escaping existing single quotes. Single quotes don't evaluate any special chars inside them anymore, so much simpler.
Logged
~ nevcairiel
~ Author of LAV Filters

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: Trouble renaming/moving files (UTF-8 issue?)
« Reply #9 on: October 21, 2014, 12:18:20 pm »

The general purpose solution is single quoting everything, and escaping existing single quotes. Single quotes don't evaluate any special chars inside them anymore, so much simpler.

That sounds like a good solution. I had thought about that, but I paused because one can't escape a single quote inside single quotes on the command line (per the bash manual "A single quote may not occur between single quotes, even when preceded by a backslash.")

But I had forgotten that MC can do any kind of pre-processing it wants before sending a string to the shell, so you're not limited by what the shell will or won't let you do. So you can just "escape it" on your own terms  ;D
Logged

Hendrik

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10943
Re: Trouble renaming/moving files (UTF-8 issue?)
« Reply #10 on: October 21, 2014, 12:23:48 pm »

That sounds like a good solution. I had thought about that, but I paused because one can't escape a single quote inside single quotes on the command line (per the bash manual "A single quote may not occur between single quotes, even when preceded by a backslash.")

You have to cheat and replace ' with '\'' .... :)
Logged
~ nevcairiel
~ Author of LAV Filters

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: Trouble renaming/moving files (UTF-8 issue?)
« Reply #11 on: October 21, 2014, 12:25:45 pm »

You have to cheat and replace ' with '\'' .... :)

Too clever!  I never would have thought of that (or only would have stumbled into it accidentally after hacking around forever).  
Logged

bob

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 13874
Re: Trouble renaming/moving files (UTF-8 issue?)
« Reply #12 on: October 21, 2014, 04:48:23 pm »

Looks like the hunch of the special shell commands was spot on, I'll work on a fix to quote and escape properly.
I'd think the same problem would exist on the Mac version.
Logged

Hendrik

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10943
Re: Trouble renaming/moving files (UTF-8 issue?)
« Reply #13 on: October 22, 2014, 05:28:33 am »

I'd think the same problem would exist on the Mac version.


Yes, it should probably affect both.
Logged
~ nevcairiel
~ Author of LAV Filters
Pages: [1]   Go Up