0

I'm using the following to rename a file:

for /f "tokens=*" %%x in (doctitle.txt) do set DOCTITLE=%%~x
move file.pdf "%DOCTITLE%.pdf"

A title string is suposed to be contained in the doctitle.txt, i.e. "The Title of a Document" (without quotes).

It works fine, if the title string is simple (does not have accents). If title string contains accents, i.e. "açaí" the result is something like "a├ºa├¡.pdf".

How to approach this issue?

I guess the best will be to replace the characters, i.e. "açaí" becoming "acai".

As a reference, I would like to add this batch script to rename a file with string (with space) from variable.

Community
  • 1
  • 1
oqrxke
  • 331
  • 1
  • 3
  • 12
  • 1
    Flagrant _mojibake_ case (try `type doctitle.txt` under `chcp 850` and then under `chcp 65001`): `chcp 65001` could help but there is poor `UTF-8` support in Windows CLI. Read [great answer by @andrewdotn to _What encoding/code page is cmd.exe using_](http://stackoverflow.com/a/17177904/3439404). – JosefZ Jul 02 '15 at 23:01
  • Great! Adding "chcp 65001" on the top of the script solved it. Thank you very much @JosefZ! But those characters, soon or latter, may cause problems. Let's say I want to replace them (as pointed in the question), is that reasonable/feasible (a good idea)? What could be done in this case? – oqrxke Jul 02 '15 at 23:24
  • That's why I can't give a full scope answer. Try [dbenham's `repl.bat` or `jrepl.bat`](http://stackoverflow.com/a/16735079/3439404) – JosefZ Jul 02 '15 at 23:33

0 Answers0