r/PowerShell • u/Radiant-Photograph46 • Jan 26 '26
Solved Processing special characters in file names
I have some files with brackets in their names and they behave very oddly with powershell. I ran this quick experiment: `@(gci)[0]` in a folder shows one of the files with brackets, then `test-path @(gci)[0]` which… returns False. Big problem here.
How do I fix this behavior? The issue is not with test-path specifically, get-fileHash also returns an empty string, and `test-path @(gci)[0].fullName` also returns False.
3
Upvotes
View all comments
Show parent comment
1
u/Affectionate_Ad_3722 Jun 15 '26
Thankyouthankyouthankyou!
That has been driving me nuts for half an hour. I've seen "-literalpath" before but never needed it. These files have [] and % and () in their names, your comment saved the day.