Rename an item, in a PowerShell provider namespace.

      Rename-Item [-path] string[] [-newName] string [-force]
              [-passThru] [-credential PSCredential] [-whatIf]
                  [-confirm] [-UseTransaction] [CommonParameters]

   -path string
       The path(s) to the item(s) to be renamed. Wildcards are permitted.

   -newName string 
       The new name for the item.

       Override restrictions that prevent the command from succeeding, apart
       from security settings. e.g. Force will create file path directories 
       or override a files read-only attribute, but will not change file permissions.

        Pass the object created by Rename-Item along the pipeline. 
   -credential PSCredential
       Use a credential to validate access to the file. Credential represents
       a user-name, such as "User64" or "Domain64\User64", or a PSCredential
       object, such as the one retrieved by using the Get-Credential cmdlet.
       If you type a user name, you will be prompted for a password.
       This parameter is not supported by any PowerShell core cmdlets or providers.
       Describe what would happen if you executed the command without
       actually executing the command.

       Prompt for confirmation before executing the command.

       Include the command in the active transaction.

       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
       -OutBuffer -OutVariable.

Standard Aliases for Rename-Item: ren, rni

Rename-Item changes the name of an item, it does not affect the content of the item being renamed.
Rename-Item cannot be used to move an item. To move and rename an item, use Move-Item.

The -Newname parameter does not accept wildcards, but you can use a -replace expression to calculate the new name.


Rename a file:

PS C:\> rename-item -path c:\docs\dump.csv -newname Report.xls

Rename all .TXT files as .LOG files in the current directory:

PS C:\> get-childitem -Path *.txt | rename-item -NewName {$ -replace ".txt",".log"}

Rename all the files in the current directory, prefixing each with "The Beatles - ":

PS C:\> get-childitem | % { rename-item $_ "The Beatles - $_"}

Rename a registry key:

PS C:\> rename-item HKLM:\Software\SS64\Demo1 -NewName Test2

“It is the function of art to renew our perception. What we are familiar with we cease to see. The writer shakes up the familiar scene, and, as if by magic, we see a new meaning in it” - Anais Nin


clear-item - Remove content from a variable or an alias
Copy-Item - Copy an item from a namespace location
get-item - Return an object that represents an item in a namespace
invoke-item - Invoke an executable or open a file (START)
move-item - Move an item from one location to another
new-item - Create a new item in a namespace
set-item - Set the value of a provider pathname
remove-item - Remove an item
StampMe - Script to rename a file with the current Date/Time
Equivalent bash command: mv - Move or rename files or directories

© Copyright 1999-2013
Some rights reserved