0

I've got a batch file that I use to rename all files in a particular folder. After renaming, there are characters that I don't recognize. It's supposed to rename

whatever file name.jpg to new file name - something.jpg

But in place of the long dash, there is a some strange character that looks like a U with a caret over it. Similar problem with the apostrophe. In place of the apostrophe, it looks like there's a character AE mashed up together. See screenshot for reference

screenshot

Here's a sample of my batch file

cd /
@echo
T:
ren "T:\Photos\19292955_somefilename1.jpg" "Casting – November Crew.jpg.jpg"
ren "T:\Photos\19293030_somefilename2.jpg" "Casting – October Crew.jpg.jpg"
ren "T:\Photos\19290568_somefilename3.jpg" "Nov – O'Reilley.jpg""
phuclv
  • 37,963
  • 15
  • 156
  • 475
user2849978
  • 1
  • 1
  • 2
  • 2
    Can you try to save your batch file in ANSI (in notepad you can choose that on the file save as dialog) – rene Nov 09 '13 at 20:47
  • you can't have long names in DOS, let alone names with spaces or dash. It's not Windows – phuclv Jun 26 '18 at 11:32

3 Answers3

0

Would adding this to the title help? chcp 65001

Sources:

  1. Using non-ASCII characters in a cmd batch file
  2. What encoding/code page is cmd.exe using?
Community
  • 1
  • 1
Claudia
  • 1,197
  • 15
  • 30
0

Use an editor such as EDITPLUS or NOTEPAD++, not a word-processor or even standard Notepad to edit batch files. Word-processors and WP-wannabes try to format the code by using control-codes.

Magoo
  • 77,302
  • 8
  • 62
  • 84
0

For those who still can't operate folders and files with long dash (em-dash) in the full path:

  1. At first use ANSI (Windows) code page in your .bat file. Not OEM (DOS) because there is no such symbol in OEM-coding table. I prefer SynWrite text editor for this purpose.

  2. Before you address to string, or before you get a string of the path containing em-dash in .bat file change code page to your local windows page (1251 fo Russia) using chcp operator.

  3. After you finish operating a string of the path containing em-dash change code page back to 866

Code for example:

chcp 1251
RENAME "c:\Users\User\AppData\Roaming\Autodesk\AutoCAD 2013 — Русский\R19.0\rus\Plotters\Plot1" Plot2
chcp 866
@pause
phuclv
  • 37,963
  • 15
  • 156
  • 475
Krapivnik
  • 1
  • 2