The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

franck (17) [Avatar] Offline
#1
Hi all

I have with 'rename-item' exactly the same problem as with 'get-acl' (see my message from Sep 19, 2007 8:03 AM 'Problem with square brackets and get-acl (no -literalpath)'

the square bracket in pathname can't be escape.

i can't rename a file with '[' or ']' in pathname

- gci 'test''[1]file.txt' - is working but - rename-item 'test''[1]file.txt' newname.txt not

I get 'rename-item: Cannot rename because item at 'test[1]file.txt' does not exist.

It 'rename-item' also buggy !!??

Greeting Franck
brucepay (155) [Avatar] Offline
#2
Re: Problem with square bracket and rename-item
Yup - it's buggy but there is a good workaround for this one.

Here's what happened. There was a push just before the release of version 1 where we went through and cleaned up most of the wildcard quoting bugs. This was done right at the end so the work was triaged pretty heavily. Only the most important things got fixed since we were locking done for RTM/RTW. We fixed all of the *-Item commands except for Rename-Item, the rational being that the Rename-Item cmdlet isn't necessary since you can use Move-Item instead and Move-Item does support the -LiteralPath parameter. Here's an example:

PS (4smilie > new-item [1].txt # create a file with [ ] in the name
Type: file


Directory: Microsoft.PowerShell.CoreFileSystem::C: empjunk


Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 9/20/2007 11:11 PM 0 [1].txt


PS (49) > move-item -literal [1].txt one[1].txt # now rename/move it...
PS (50) > ls *`]*.txt


Directory: Microsoft.PowerShell.CoreFileSystem::C: empjunk


Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 9/20/2007 11:11 PM 0 one[1].txt

As Jeffrey Snover is so fond of saying, to ship is to choose. Some things get fixed, some don't. The Acl thing should have been fixed because there is no good workaround. The Rename-Item bug is less of an issue except, of course, when users encounter the problem and get annoyed with us. This should, at least, be rel-noted...

-bruce