ayoisaiah / f2

F2 is a cross-platform command-line tool for batch renaming files and directories quickly and safely. Written in Go!
https://f2.freshman.tech
MIT License
866 stars 38 forks source link

Filename variable [f} doesn't recognize filename with UTF-8 characters #65

Closed f0sh closed 6 months ago

f0sh commented 6 months ago

I would like to rename a file which contains chinese characters. However I run into e problem, where f2 doesn't recognise the filename properly:

$ls -1
'101. 適合學中文的電視節目:誰來晚餐.txt'
'102. 玫瑰少年與LGBTQI'
'103. 旅行中遇到的麻煩 (1)'
'44. Guide.pdf'
'45. Guide.pdf'

$f2 -E ".txt" -r "{f}.txt"
*————————————————————————————————————*————————————————————————*————————*
|              ORIGINAL              |        RENAMED         | STATUS |
*————————————————————————————————————*————————————————————————*————————*
| 102. 玫瑰少年與LGBTQI              | 102.txt                | ok     |
| 103. 旅行中遇到的麻煩 (1)          | 103.txt                | ok     |
| 44. Guide.pdf                      | 44. Guide.txt          | ok     |
| 45. Guide.pdf                      | 45. Guide.txt          | ok     |

As visiable the {f} chaptures the ascii letters fine, however ignores the chinese characters.

Expected output should have been:

*————————————————————————————————————*———————————————————————————*————————*
|              ORIGINAL              |        RENAMED            | STATUS |
*————————————————————————————————————*———————————————————————————*————————*
| 102. 玫瑰少年與LGBTQI               | 102. 玫瑰少年與LGBTQI.txt   | ok     |
| 103. 旅行中遇到的麻煩 (1)           | 103. 旅行中遇到的麻煩 (1).txt  | ok     |
| 44. Guide.pdf                      | 44. Guide.txt              | ok     |
| 45. Guide.pdf                      | 45. Guide.txt              | ok     |

Using Windows 11 Version 10.0.2263 both with Windows CommandLine and with WSL on Debian11/Zsh.

ayoisaiah commented 6 months ago

@f0sh This is the correct behaviour.

F2 interprets 102, 103, 44. Guide, and 45. Guide as the filenames ({f}). Everything after the last dot in the name is interpreted as the file extension ({ext}), and that's why its omitted from the output.