Page 1 of 1

funny chars in xcopy

Posted: 08 May 2017 11:16
by abenitez77
I did an xcopy command to copy the path and file names of about 500,000 files and saved it to a txt file. Some filenames did not keep the accent/funny chars that are part of the file names.

i.e.
This is the actual file name:
1027948_16356344_wk 35 @NIVEA BODY@48965 Body 625ml 77240 CrŠme Soft 250-200ml 24253 Inshower @ AD @ $0 30 $0 50 $0 05 @ RCWC EF_VS.xlsm

This was the result from the xcopy:
1027948_16356344_wk 35 @NIVEA BODY@48965 Body 625ml 77240 Crème Soft 250-200ml 24253 Inshower @ AD @ $0 30 $0 50 $0 05 @ RCWC EF_VS.xlsm

How can I get the correct filename to print as is?

my xcopy command saved in a batch file:
dir "\\USATL02ERAS40\auditfiles\Loblaws\LCL_2016\Z-DT\NDS 2016\Mailtrax NDS 2016\*.xls*" /A /B /S > XLSVndDir2.txt

Re: funny chars in xcopy

Posted: 08 May 2017 13:03
by aGerman
Try to change the code page beforehand. Assuming Windows-1252 as your default ANSI code page ...

Code: Select all

>nul chcp 1252


Steffen

Re: funny chars in xcopy

Posted: 09 May 2017 07:56
by abenitez77
that did not work, thanks

Re: funny chars in xcopy

Posted: 09 May 2017 13:22
by aGerman
Sorry but then I don't get you.

Steffen

Re: funny chars in xcopy

Posted: 09 May 2017 18:30
by ShadowThief
It might not be 1252. You'll have to play around with the number before you find the right one.

If you open a command prompt and just type CHCP, what number appears?

Re: funny chars in xcopy

Posted: 10 May 2017 06:27
by abenitez77
Active code page: 437

Re: funny chars in xcopy

Posted: 10 May 2017 07:44
by Squashman
abenitez77 wrote:my xcopy command saved in a batch file:
dir "\\USATL02ERAS40\auditfiles\Loblaws\LCL_2016\Z-DT\NDS 2016\Mailtrax NDS 2016\*.xls*" /A /B /S > XLSVndDir2.txt

That is a funny XCOPY command.

Re: funny chars in xcopy

Posted: 10 May 2017 08:57
by abenitez77
I meant dir...my head was somewhere else while multitasking...

Re: funny chars in xcopy

Posted: 10 May 2017 09:52
by aGerman
OEM code page 437 should be related to ANSI code page 1252.

I saved the following code to Crème.bat

Code: Select all

@echo off
>"test.txt" dir /a-d /b
Content of test.txt after running

Code: Select all

CrŠme.bat
test.txt


Code with chcp added

Code: Select all

@echo off
>nul chcp 1252
>"test.txt" dir /a-d /b
test.txt

Code: Select all

Crème.bat
test.txt


If you're not sure if 1252 is your current ANSI code page run info.bat
viewtopic.php?f=3&t=7420&p=49133#p49133

Steffen

Re: funny chars in xcopy

Posted: 10 May 2017 14:42
by abenitez77
The results I got back were correct:

CrŠme.bat
test.txt

seems the issue is in the SQL Server Import I am doing.

Thanks!