Escaping %’s in file-/folder-names at the command-line



As an IT administrator, you may encounter a situation where you need to escape special characters in file or folder names at the command line. Special characters can be either punctuation characters or non-alphanumeric characters such as @, #, $, %, ^, &, *, (, ), {, }, [, ].

The general rule for escaping special characters in file or folder names is to use either a backslash (\\) or double quotation marks (“”). The backslash is used to escape special characters, while the double quotation marks are used to enclose a series of characters that would otherwise be interpreted as one single item.

When using the backslash to escape special characters in file or folder names, it is important to remember that the backslash must be preceded by a regular character or whitespace character. This means that if you are trying to escape a special character that appears at the beginning of the file or folder name, you should use a double quotation mark (“”) instead.

For example, if you were trying to escape a folder named “#test”, you would use the following command at the command line:

mkDIR “\\#test”

In this example, the backslash is used to escape the leading # character, and the double quotation marks are used to enclose the entire folder name.

On the other hand, if you were trying to escape a file named “$file.txt”, you would use the following command at the command line:

COPY “$file.txt” .

In this example, the double quotation marks are used to enclose the file name, and the period (.) is used to indicate that the file should be copied to the current directory.

It is also important to note that the backslash and double quotation marks must be used in combination in order to escape special characters in file or folder names. For example, if you were trying to escape a file named “#file.txt”, you would not be able to use just the backslash. You would need to use both the backslash and double quotation marks in order to properly escape the special character.

In summary, as an IT administrator, it is important to remember that you can use either a backslash (\\) or double quotation marks (“”) to escape special characters in file or folder names at the command line. The backslash must be preceded by a regular character or whitespace character, and the double quotation marks must be used in combination with the backslash in order to properly escape a special character.

Inquire Now

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Find your next full or part-time role here

ScaleDesk can either help you find your next full time gig or a part time side gig where you can create extra income!

Onboard with us once
Skip HR screening and go to the final interview with with only your resume and a video interview you never have to redo
Get paid electronically every month for the hours you work
We will be your reference even if you work for us once

IT Teams: Use ScaleDesk to augment your team

Schedule Demo