If I run something that returns with a & or some other character that has special meaning, and I try to use it in a script, how would I escape it?
An example would be if I shared a local account with someone in the same computer, and I had a username that says John & Matt. Putting a batch file in the Desktop directory that had something like this:
@ECHO OFF
echo %~dp0
It would return something like this:
C:\Users\John
The system cannot find the path specified.
And the whole script from that point on breaks if I try to keep going. If anyone knows a way to make the whole path appear, I'd appreciate it.
EDIT: I didn't clarify this enough earlier. Sorry about that. Not really good at explaining, but if I try to use %~dp0 in a variable, and stack more things on top of that, something like
SETLOCAL
set loc=%~dp0
rename "%~dp0Dir\Dir1\Dir2\File.txt" "Something.txt"
It would probably confuse the rename command if I put another set of quotation marks when I'm declaring a variable to fix that issue.
The batch file that I was trying to create basically deletes a file where the batch file is located, replaces it with another file in a subfolder located inside the directory where the batch file is, and renames it to something else.