Powershell: moving items not working when filenames that have chars [ ] -
Powershell: moving items not working when filenames that have chars [ ] -
quick question moving items powershell: know why next script not work when filename has [ or ] chars on it? (ex.: file1[vt].txt)
ls j:\ | foreach { $itemname = $_.name.replace('.', ' ') $destination = ls | { $itemname -match $_.name } | select -first 1 if ($destination -ne $null) { mi $_.pspath $destination.pspath -verbose -whatif } }
for instance, move file if it's called file1.txt ignore files named file1[vt].txt. i'm under assumption it's not finding path file when has chars [ or ] on name. ideas?
just using -literalpath
parameter move-item
ls j:\ | foreach { $itemname = $_.name.replace('.', ' ') $destination = ls | { $itemname -match $_.name } | select -first 1 if( $destination -ne $null){ mi -literalpath $_.pspath $destination.pspath -verbose -whatif } }
powershell filenames
Comments
Post a Comment