I want to do a very simple thing: Copy a file.
Copy is a simple (and fundamental) command. It should be easy, but it seems to be complicated when it comes to Unicode filenames (using English XP, cmd.exe, and a .cmd script).
I have managed to create a .cmd file with the Unicode filenames, as follows
:: To create the final .cmd script :: set SRCE=D:\_cmd\cpp set DEST=H%SRCE:~1% cmd.exe /U /c DIR /A:-D /s /b "%SRCE%" >"SRCE.UTF16" cmd.exe /U /c DIR /A:-D /s /b "%DEST%" >"DEST.UTF16" ConvUTF.exe 1628 "DEST.UTF16" "DEST.UTF-8" ConvUTF.exe 1628 "SRCE.UTF16" "SRCE.UTF-8" :: Then, with `sed.exe`, `diff.exe`, and `ConvUTF.exe` again... :: the resulting UTF-8 (or UTF16) .cmd file looks like this... :: copy "D:\_cmd\cpp\ā.क.test" "H:\_cmd\cpp\" The copy command works fine when I run it directly at the command prompt, but fails, when used in the .cmd script.
The UTF-8 .cmd errors out with: The system cannot find the file specified
The UTF16 .cmd doesn't get past the first NULL-byte (of the first character), and just exits.
Is there some way to do it from a .cmd script? (I want to use the cmd.exe shell)
Perhaps there is a utility program which can be called from my .cmd...
All suggestions are welcome.
PS. To clarify the manin issue... I don't care about how Unicode filenames display in the console window (That just doesn't happen for most non-latin-based letters in the cmd.exe window)... I am only interesterd in being able to copy a file which has Unicode letters in its filename- via a batch .cmd "script".
xcopy c:\somefile.txt z:\somefile.txt /u /y exitxcopy c:\somefile.txt z:\somefile.txt /u /yworks, because your example uses filenames whose "letters" do not range beyond a single-byte char-set. My problem arises when I want to copy a file with Unicode characters in its filename.. by Unicode, I mean characters which have a Unicode CodePoint greater than 127 (hex 7F) .. as per my example above: "ā.क.test"..ऊis not known to the current console font.. However the underlying character is stillऊand the copy will succeed (It does on my setup, but there may be other issues involved. So, I don't have a problem with that point (it is a pain! but not a show-stopper)... The issue I have is that the copy fails when the command is called from within a .cmd script.. It doesn't seem to handle any type of Unicode: UTF-8 and UTF16 both fail.. and UTF16 is native to Windows!