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

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -