#11 2016-03-29 21:13

Andrew
Senior Member
Registered: 2008-05-22
Posts: 542

Re: [BUG] Batch code will not find filenames if...

den4b wrote:

A bat/cmd file with CHCP 65001 and REN command with UTF8 encoded file names is working fine, in all tests so far.
...
So far there are no issues with using CHCP 65001.

Maybe I'm misunderstanding what exactly you're doing, Denis. Are you sure you are testing with UTF-8 characters that cannot also be encoded in ANSI?

Here's my simple test: I have a file named αβγδε.txt that I want to rename. Now I cannot save those 5 characters in an ANSI text file so I save the following as a UTF-8 or Unicode batch file instead:

chcp 65001
ren αβγδε.txt abcde.txt

Guess what - no batch files except for ANSI-encoded ones even run at the command line, which is precisely what that StackOverflow comment pointed out.

Now my question is - how are you getting such non-ANSI UTF-8 filenames to work in a batch file?

Offline

#12 2016-03-29 22:57

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,479

Re: [BUG] Batch code will not find filenames if...

Are you sure you are testing with UTF-8 characters that cannot also be encoded in ANSI?

100% sure. File is UTF8 encoded without BOM.

Here's my simple test: I have a file named αβγδε.txt that I want to rename.

Tested your example and it worked as expected. Tried even Chinese glyphs, no problems. File was saved as UTF8 without BOM.

What's your OS?

Offline

#13 2016-03-30 17:00

Andrew
Senior Member
Registered: 2008-05-22
Posts: 542

Re: [BUG] Batch code will not find filenames if...

Windows 10. Saved the batch file with ANSI and UTF-8 encoding using Notepad.

Ok, so found the source of the problem. Notepad apparently can save as UTF-8 only with BOM, and such batch files won't run. Perhaps a REMark might need to be added to the file stating that only editors that can save the file as UTF-8 without a BOM should be used.

Offline

#14 2016-04-02 19:26

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,479

Re: [BUG] Batch code will not find filenames if...

Andrew wrote:

Perhaps a REMark might need to be added to the file stating that only editors that can save the file as UTF-8 without a BOM should be used.

ReNamer generates a functioning batch file, that is what matters. User side modifications to this file may or may not break it, but the resulting issues are outside of the scope of this functionality.

Offline

Board footer

Powered by FluxBB