Brock Elgart
Brock Elgart

Reputation: 154

Copying csv in batch file causes file to be corrupted

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?

Upvotes: 0

Views: 519

Answers (2)

James L.
James L.

Reputation: 9451

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"

Upvotes: 0

Tashfi Nowroz
Tashfi Nowroz

Reputation: 140

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...

Upvotes: 0

Related Questions