Migrating about 200,000 files to OneDrive for business, and discovered that there are a few characters they don't like - the biggest offender is #
. I have about 3,000 files with a hash, and I'd like to replace them all with just No.
. For example, old: File#3.txt
new: File No.3.txt
I tried using a PowerShell script, but it doesn't like #
either:
Get-ChildItem -Filter "*#*" -Recurse |
Rename-Item -NewName { $_.name -replace '#',' No. ' }
I'm not having much luck figuring out the syntax for reserved characters - I tried \#
, #\
, '*#*'
, no luck.
Can anyone shed light on this or provide a quick method to recursively replace all of these hash tags?
Thanks.
PowerShell uses the Backtick (`) as an escape character, and double quotes to evaluate content:
or
Both will work.
This would also work,
Because the PowerShell parser is smart enough to figure out your intent.