funny chars in xcopy

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
abenitez77
Posts: 7
Joined: 08 May 2017 11:10

funny chars in xcopy

#1 Post by abenitez77 » 08 May 2017 11:16

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

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: funny chars in xcopy

#2 Post by aGerman » 08 May 2017 13:03

Try to change the code page beforehand. Assuming Windows-1252 as your default ANSI code page ...

Code: Select all

>nul chcp 1252


Steffen

abenitez77
Posts: 7
Joined: 08 May 2017 11:10

Re: funny chars in xcopy

#3 Post by abenitez77 » 09 May 2017 07:56

that did not work, thanks

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: funny chars in xcopy

#4 Post by aGerman » 09 May 2017 13:22

Sorry but then I don't get you.

Steffen

ShadowThief
Expert
Posts: 1160
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: funny chars in xcopy

#5 Post by ShadowThief » 09 May 2017 18:30

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?

abenitez77
Posts: 7
Joined: 08 May 2017 11:10

Re: funny chars in xcopy

#6 Post by abenitez77 » 10 May 2017 06:27

Active code page: 437

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: funny chars in xcopy

#7 Post by Squashman » 10 May 2017 07:44

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.

abenitez77
Posts: 7
Joined: 08 May 2017 11:10

Re: funny chars in xcopy

#8 Post by abenitez77 » 10 May 2017 08:57

I meant dir...my head was somewhere else while multitasking...

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: funny chars in xcopy

#9 Post by aGerman » 10 May 2017 09:52

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

abenitez77
Posts: 7
Joined: 08 May 2017 11:10

Re: funny chars in xcopy

#10 Post by abenitez77 » 10 May 2017 14:42

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!

Post Reply