plus sign in file name

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
lazna
Posts: 62
Joined: 27 Dec 2012 10:54

plus sign in file name

#1 Post by lazna » 12 Jun 2024 03:57

Copying some binaries from one directory to another utilizing 'copy' command, but facing issues when filename contain plus sign (in my case libstdc++-6.dll) and is not doublequoted. Probably the copy command misinterprete it as a file combining operation. Searching for any description about this issue, but found nothing... Is this a known issue?

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

Re: plus sign in file name

#2 Post by ShadowThief » 12 Jun 2024 06:35

Not a known issue per se, but a known and expected behavior. This is the very last sentence of copy /? -
To append files, specify a single file for destination, but multiple files for source (using wildcards or file1+file2+file3 format).
Like all other special characters, you'll have to wrap the filename in quotes in order for the plus signs to behave like regular text.

lazna
Posts: 62
Joined: 27 Dec 2012 10:54

Re: plus sign in file name

#3 Post by lazna » 12 Jun 2024 09:33

ShadowThief wrote:
12 Jun 2024 06:35
Not a known issue per se, but a known and expected behavior. This is the very last sentence of copy /? -
To append files, specify a single file for destination, but multiple files for source (using wildcards or file1+file2+file3 format).
Like all other special characters, you'll have to wrap the filename in quotes in order for the plus signs to behave like regular text.
I read this, but there is also list characters disallowed in filenames https://learn.microsoft.com/en-us/windo ... ing-a-file where plus sign is not listed. I wrote this article for another people who may facing this issue, and did not came to their mind the plus sign inde of filename automatically turn on file appending function unintendly.

BTW: What about to extend this page https://ss64.com/nt/copy.html by notice "in case name some of your files could contain plus sign, enclose it with doublequotes" or something like this??

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

Re: plus sign in file name

#4 Post by Squashman » 12 Jun 2024 11:05

Don't use COPY. Use XCOPY or ROBOCOPY.

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

Re: plus sign in file name

#5 Post by ShadowThief » 12 Jun 2024 21:14

lazna wrote:
12 Jun 2024 09:33
ShadowThief wrote:
12 Jun 2024 06:35
Not a known issue per se, but a known and expected behavior. This is the very last sentence of copy /? -
To append files, specify a single file for destination, but multiple files for source (using wildcards or file1+file2+file3 format).
Like all other special characters, you'll have to wrap the filename in quotes in order for the plus signs to behave like regular text.
I read this, but there is also list characters disallowed in filenames https://learn.microsoft.com/en-us/windo ... ing-a-file where plus sign is not listed. I wrote this article for another people who may facing this issue, and did not came to their mind the plus sign inde of filename automatically turn on file appending function unintendly.
Only the copy command will break with plus signs, whereas all commands break with those other listed characters
lazna wrote:
12 Jun 2024 09:33
BTW: What about to extend this page https://ss64.com/nt/copy.html by notice "in case name some of your files could contain plus sign, enclose it with doublequotes" or something like this??
Nobody here controls that page, but you're welcome to post your suggestion on that site's forum. I don't know how likely the change will happen given that plus signs are clearly visible in the usage text indicating that they have special significance and the number one rule of interacting with any filenames is "put quotes around everything," but the owner is usually fairly open to recommendations.

Post Reply