1

I have mounted a linux shared folder. In the folder, there is a sub-folder . \ (dot space) which I need to access. With the command prompt I can access it using the 8dot3 notation of short names, but I need to access it with PowerShell.

Set-Location and cd will throw an error on paths with folder names with trailing spaces (path does not exist).

stackprotector
  • 10,498
  • 4
  • 35
  • 64
d82k
  • 379
  • 7
  • 17

1 Answers1

1

Windows still does not have the best support for folder names with trailing spaces. You can use a workaround with symbolic links. Create a symbolic link to the folder that contains a trailing space in its name using the mklink command of an elevated Windows command prompt (not available in PS as it is a command and not a tool) and define your path as a UNC path:

mklink /D C:\MyLink "\\?\C:\path\to\folder\. "

After that you can do:

cd C:\MyLink

or:

Set-Location -LiteralPath C:\MyLink

in PowerShell to work from your directory that has a trailing space in its name.

You can read more on operations with folder names containing trailing spaces in my answer here.

stackprotector
  • 10,498
  • 4
  • 35
  • 64
  • This helps, I was able to access the folder. I also created a symbolic link to the specific file i need. – d82k May 12 '20 at 14:11