Execute .bat file with unicode characters

Winston
Lounger
Posts: 32
Joined: 07 Jun 2010, 17:51

Execute .bat file with unicode characters

Post by Winston »

I started to use a batch file to move about 300,000 files. The problem I have run into is Unicode characters. I can get the characters to display properly but I am not able to execute the batch file in the cmd window.

Move "F:\Departments\Japanese Staff\Visiting Staff\JStaff\My Documents\デスクトップのデータ移動\080304 デスクトップのデータ移動\長嶋フォルタ\関係\出張2006年7月\Backup\DH Backup bfore Shutdown\DH Robot\DD Robot#3 6-24-2006\LEK_L4-G.JBI" "O:\Departments\Japanese Staff\Visiting Staff\JStaff\My Documents\デスクトップのデータ移動\080304 デスクトップのデータ移動\長嶋フォルタ\関係\出張2006年7月\Backup\DH Backup bfore Shutdown\DH Robot\DD Robot#3 6-24-2006"

I have all the files that need to be moved all ready in a .txt file. The example above is from that .txt file.

Is there a way to use the cmd for the Unicode characters to move the files? Or, is there another way to move about 300,000 + files that I have stored in that .txt file?


Thank you,

Winston

User avatar
HansV
Administrator
Posts: 78485
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Execute .bat file with unicode characters

Post by HansV »

Try the following line at the beginning of the batch file

chcp 65001

(this sets the code page to UTF-8 Unicode), or

chcp 932

(this sets the code page to Japanese).

You may want to set the command prompt window to use Lucida Console instead of the default font (menu button > Defaults > Font tab).
Best wishes,
Hans

Winston
Lounger
Posts: 32
Joined: 07 Jun 2010, 17:51

Re: Execute .bat file with unicode characters

Post by Winston »

Thank you, I will give it try first thing tomorrow morning.

User avatar
John Gray
PlatinumLounger
Posts: 5408
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Execute .bat file with unicode characters

Post by John Gray »

I've never come across this problem, but some research shows that BATch files don't much like Unicode characters.
If you were to attempt to use up-to-8 character 'short names' for the move, for each directory with Japanese characters, you might get somewhere. That's assuming that the Japanese characters get turned into ASCII! Please let us know what you get...

DIR /X should give you these short names...
(as I remember Hans telling me/someone recently!)
John Gray

"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...

Winston
Lounger
Posts: 32
Joined: 07 Jun 2010, 17:51

Re: Execute .bat file with unicode characters

Post by Winston »

From what I have been reading there are a lot of people that cannot use Unicode characters in a .bat file but no concrete solutions to make it work. I have tried HansV's suggestions and they did not work either.

I have a search utility that generates a csv file. I used Excel to concatenate "Move" on the front of the file location, file name, and then the location where the file needs to me moved too. I had already thought about using the short names but the search utility does not generate those names. I have asked one of the Japanese staff to bring me a laptop with and I was going to see if I could get the .bat file to execute using a Japanese version of Windows.

If you have any suggestions on a better way to move that many files please let me know. I still have 111,029 files with Unicode characters that need to be moved.

Thank You,

Winston

User avatar
John Gray
PlatinumLounger
Posts: 5408
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Execute .bat file with unicode characters

Post by John Gray »

Are you saving that DIR /X does not show the Japanese characters in a directory name as something like DIRNAM~1 ?
I was hoping it would...
John Gray

"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...

Winston
Lounger
Posts: 32
Joined: 07 Jun 2010, 17:51

Re: Execute .bat file with unicode characters

Post by Winston »

Here is a screen shot of the cmd window with the dir /x. It does not display short names with files that have Unicode characters. I used the command line on my computer and the server. Both of them show the same results. However, if I copy one of those files to my C: drive it will display a short name that has Unicode characters.

Winston
You do not have the required permissions to view the files attached to this post.

User avatar
John Gray
PlatinumLounger
Posts: 5408
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Execute .bat file with unicode characters

Post by John Gray »

Thank you! That puts the kybosh on my idea, then!
John Gray

"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...