Benjamin S. Sorterup
Benjamin S. Sorterup

Reputation: 203

Cannot find path cause of weird path name

I have a path that looks like this:

$path = path\to\weird\filename\PUBLISERET - Dalager 1, Brøndby - Leveringsaftale D12-24311 1.0.pdf

When I do:

Set-ItemProperty -LiteralPath $path -Name IsReadOnly -Value $true

I tells me that the path doesn't exist even though it does. I believe it is because of the file name. What can I do?

Upvotes: 1

Views: 189

Answers (2)

JosefZ
JosefZ

Reputation: 30103

Dmitriy Kapitanov's answer is right: put single quotes around the path. Proof:

PS D:\PShell> $path = 'D:\bat\Unusual Names\Türkçe (Türkiye)\PUBLISERET - Dalager 1, Brøndby - Leveringsaftale D12-24311 1.0.pdf'
PS D:\PShell> Get-ItemProperty $path


    Directory: D:\bat\Unusual Names\Türkçe (Türkiye)


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---        31.08.2015     17:55      34429 PUBLISERET - Dalager 1, Brøndby - Leveringsaftale
                                             D12-24311 1.0.pdf


PS D:\PShell> Set-ItemProperty -LiteralPath $path -Name IsReadOnly -Value $true
PS D:\PShell> Get-ItemProperty $path


    Directory: D:\bat\Unusual Names\Türkçe (Türkiye)


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-ar--        31.08.2015     17:55      34429 PUBLISERET - Dalager 1, Brøndby - Leveringsaftale
                                             D12-24311 1.0.pdf


PS D:\PShell>

Upvotes: 1

here_for_python
here_for_python

Reputation: 41

Try putting single quotes around the path.

$path = 'path\to\weird\filename\PUBLISERET - Dalager 1, Brøndby - Leveringsaftale D12-24311 1.0.pdf'

Upvotes: 2

Related Questions