Copying csv in batch file causes file to be corrupted

506 Views Asked by At

I use the following command to copy a csv (with the date in the name) to a directory called "read": copy "C:\Users\Brock\Documents\Dropbox\dir\test\file????????.csv" "C:\Users\Brock\Documents\Dropbox\dir\test\file\read\file.csv"

When it is copied over there is some sort of invalid character (looks sort of like "->") that is causing Salesforce DataLoader to be unable to read the file.

Why is my file being corrupted and how can I prevent this from happening?

2

There are 2 best solutions below

1
Tashfi Nowroz On
copy "C:\Users\Brock\Documents\Dropbox\dir\test\file.csv" "C:\Users\Brock\Documents\Dropbox\dir\test\file\read\file.csv" /a /v

Try This...

0
James L. On

The CMD environment is detecting that the file is an ASCII file and is adding the ASCII EOF character (→) [0x26d, 0x1Ah] to the end of the newly copied file.

If you add the /b switch to the copy command, it will copy the file using binary mode and won't add the ASCII EOF character to the end of the copied file.

copy /b "C:\Users\Brock\Documents\Dropbox\dir\test\file????????.csv" "C:\Users\Brock\Documents\Dropbox\dir\test\file\read\file.csv"