< Back

Rename-LongItem

Sun Jan 19, 2020 5:59 pm

NAME Rename-LongItem



SYNOPSIS

Renames an item in a AlphaFS FileSystem provider namespace.





SYNTAX

Rename-LongItem [-Path] <String> [-NewName] <String> [-Force <SwitchParameter>] [<CommonParameters>]



Rename-LongItem [-Path] <String> [-NewExtension] <String> [-Force <SwitchParameter>] [<CommonParameters>]





DESCRIPTION

The Rename-LongItem cmdlet changes the name of a specified item. This cmdlet does not affect the content of the

item being renamed.





PARAMETERS

-Path <String>

Specifies the path to the item to rename.



Required? true

Position? 0

Default value

Accept pipeline input? True (ByPropertyName, ByValue)

Accept wildcard characters? false



-NewName <String>

Specifies the new name of the item. Enter only a name, not a path and name.



You cannot use wildcard characters in the value of NewName. To specify a name for multiple files, use the

Replace operator in a regular expression. For more information about the Replace operator, type "get-help

about_comparison_operators". For a demonstration, see the examples.



Required? true

Position? 1

Default value

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-Force [<SwitchParameter>]

Allows the cmdlet to rename items that cannot otherwise be changed, such as read-only files.

Warning: existing files will be replaced when used with this switch



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-NewExtension <String>

Reanme only the file extension while retaining the file name.



Required? true

Position? 1

Default value

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

System.String













OUTPUTS

None

This cmdlet does not return any output.









-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Rename-LongItem -path C:\\temp\\drivers.txt -NewName d1.txt -Verbose -Confirm:$false



This command renames the file drivers.txt to d1.txt

-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Get-LongChildItem -Path C:\\temp\\drivers.txt |

Rename-LongItem -NewName {'prefix' + $_.basename + 'Suffix' + $_.extension }



the file 'drivers.txt' is renamed by piping the output of 'Get-LongChildItem' to Rename-LongItem. The newfilename

is created by adding a prefix and a suffix to the filename resulting in the following newname:

'PrefixdriversSuffix.txt'.

-------------------------- EXAMPLE 3 --------------------------



PS C:\\>Get-ChildItem -Path C:\\temp -Filter *.txt | Rename-LongItem -NewExtension log -Confirm:$false



VERBOSE: Performing the operation "Changing Extension" on target "Item: C:\\temp\\d1.txt Destination:

C:\\temp\\d1.log".

VERBOSE: Rename-LongItem:

C:\\temp\\d1.txt

C:\\temp\\d1.log



VERBOSE: Performing the operation "Changing Extension" on target "Item: C:\\temp\\d2.txt Destination:

C:\\temp\\d2.log".

VERBOSE: Rename-LongItem:

C:\\temp\\d2.txt

C:\\temp\\d2.log



This command gets all the text files in c:\\temp and pipes them to Rename-LongItem which then renames each text

file extension from *.txt to *.log

Note: the name os the file is retained(in other words remains unchanged)



RELATED LINKS