Rename Files having EmDash using a Batch File

白昼怎懂夜的黑 提交于 2021-02-08 10:24:18

问题


I have a ton of files containing em dashes within the file name. I am having trouble renaming them, as cmd apparently fails to recognize it, and converts emdash into a regular dash. As a result I get the following error after I run the ren command:

ren "MyFile With – EmDash.txt" "MyFile.txt"   
The system cannot find the file specified.

Things I have tried

  1. Inserting chcp 65001 at start of batch code.

    This command does not seem to work.

  2. Saving the batch file as ANSI in Notepad

What this does is basically the following:

ren "MyFile With û EmDash.txt" "MyFile.txt"
The system cannot find the file specified.

As one can guess apparently saving ANSI format changes a character stored as em dash in notepad to û when batch file runs in a cmd window.

I have got dozens of files which need this renaming, and this would be monotonous to do so without a batch script.

来源:https://stackoverflow.com/questions/53693969/rename-files-having-emdash-using-a-batch-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!