1

I am trying to write a bat file to copy some files into a new directory (which exists).

Here is my command:

copy ".\050-9800-JJJ-DSC-BAW-MEE-00019-01*.pdf" "T:\201201.00 TCO - Tengiz, Kazakhstan\12.0-Submittals\100% IFC\DocsForVoid"

Notice that the destination path has a directory name that contains "%". When I see the output in powershell I get the error that the system cannot find the path specified. The path echoed in the command does not contain the "%" character . . . please note that I did not name this directory, and it may be problematic to rename it. Is there any way to get this to work?

Here is powershell output (sample):

T:\201201.00 TCO - Tengiz, Kazakhstan\08.6-Document Control\CW985786 Documents to be Uploaded to POL\015-C041-ITM-TRN-BA
W-FGP-00159>copy ".\050-9800-JJJ-DSC-BAW-MEE-00019-01*.pdf" "T:\201201.00 TCO - Tengiz, Kazakhstan\12.0-Submittals\100 I
FC\DocsForVoid"
.\050-9800-JJJ-DSC-BAW-MEE-00019-01_H04.pdf
The system cannot find the path specified.
7
  • What version of powershell? I can't reproduce the issue.
    – EBGreen
    May 4, 2015 at 17:25
  • Not sure . . . is there a way to get powershell to tell me what version it is? May 4, 2015 at 17:43
  • $host.Version at the command line
    – EBGreen
    May 4, 2015 at 17:57
  • That error message looks more like cmd.exe than PowerShell.
    – dangph
    May 5, 2015 at 7:27
  • @EBGreen 2.0.-1.-1 (Major, Minor, Build, Revision) . . . I've not seen -1 before like that. May 5, 2015 at 15:08

1 Answer 1

0

Try putting two && instead of one. This is will escape the special character.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.