Powershell Bug in copy/move/rename when filename contains [square bracket characters]?
Fresh3 days ago
Mar 15, 202628901 viewsConfidence Score0%
0%
Problem
Please pardon a noob question, but I've been completely baffled by this one. I have a "depositor" directory where user-submitted files arrive, and have no control over the incoming file names. I created a parser in PS which quite successfully moves files (based on file name content) to an appropria…
Error Output
cd $folderpath
foreach ($i in get-childitem $folderpath) {
if ($i.mode.substring(0,1) -ne “d”) {
$name = $i.name.replace("[","_")
…Unverified for your environment
Select your OS to check compatibility.
1 Fix
Canonical Fix
Unverified Fix
New Fix – Awaiting Verification
Fix for: Powershell Bug in copy/move/rename when filename contains [square bracket characters]?
Low Risk
Unless you use , square brackets cause real problems with character escaping. The problem comes from PowerShell de-escaping the strings multiple times internally and using special characters for pattern matching. Getting PowerShell to correctly reco…
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix