Windows – stand-alone* wildcard for the user documents folder

batch filewildcardswindows

I'm working on a batch script that deletes folders & files and I want to know if there is a stand-alone/singular wildcard variable that represtnts:

C:\Users\%USERNAME%\Documents

I know about C:\Users\%USERNAME\Documents and %USERPROFILE%\Documents, but I'm looking for something along the lines of %DOCUMENTS%. I tried the %DOCUMENTS% wildcard, but it did nothing. Does such a wildcard exist? I haven't been able to find this information anywhere on the internet yet…

  • When I reference "stand-alone", I am speaking about wildcards that don't have any other path variables included. An example would be %SYSTEMROOT%.

Best Answer

Is there an environment variable for C:\Users\%USERNAME%\Documents?

No. However there is nothing stopping you creating one:

set DOCUMENTS=%USERPROFILE%\documents

To make it permanent:

setx DOCUMENTS %USERPROFILE%\documents /m

Notes:

  • /m sets the value for the local machine, so all users will see it
  • setx requires a restart of any currently open cmd shells.

Further Reading

Related Question