< Back

Move-LongItem

Sun Jan 19, 2020 5:59 pm

NAME Move-LongItem



SYNOPSIS

Move file\\folders





SYNTAX

Move-LongItem [-Path] <String> [-Destination] <String> [-Force <SwitchParameter>] [<CommonParameters>]





DESCRIPTION

Moves an item from one location to another.





PARAMETERS

-Path <String>

Specifies the path to the current location of the item.Wildcards are NOT permitted.



Required? true

Position? 0

Default value

Accept pipeline input? True (ByPropertyName, ByValue)

Accept wildcard characters? false



-Destination <String>

Specifies the path to the location where the items are being moved.



Required? true

Position? 1

Default value

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-Force [<SwitchParameter>]

Allows the cmdlet to move an item that writes over an existing read-only item



Required? false

Position? named

Default value

Accept pipeline input? false

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:\\>Move-LongItem -path C:\\temp\\test.txt -destination C:\\Temp\\folder1\\tst.txt



This command moves the Test.txt file from the C:\\temp to the C:\\Temp\\folder1 directory and renames it from

"test.txt" to "tst.txt".

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



PS C:\\>Move-LongItem -Path C:\\temp\\logfiles -Destination C:\\temp\\newlogfiles



This command moves the C:\\Temp\\logfiles directory and its contents to the C:\\temp\\newLogfiles directory. The

logfiles directory, and all of its subdirectories and files, then appear in the newLogfiles directory.

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



PS C:\\>Get-LongChildItem -Path C:\\temp -Filter *.csv -Recurse | Move-longItem -Destination C:\\temp\\logs -Verbose



This command moves all of the csv files from the c:\\temp directory and all subdirectories, recursively, to the

C:\\temp\\logs directory.



The command uses the Get-LongChildItem cmdlet to get all of the child items in the temp directory and its

subdirectories that have a *.csv file name extension. It uses the Recurse parameter to make the retrieval

recursive and the filter parameter to limit the retrieval to *.csv files.



The pipeline operator (|) sends the results of this command to Move-LongItem, which moves the csv files to the

logs directory.



If files being moved to C:\\temp\\logs have the same name, Move-LongItem displays an warning and continues, but it

moves only one file with each name to C:\\temp\\logs. The other files remain in their original directories.



If the logs directory (or any other element of the destination path) does not exist, the command fails. The

missing directory is not created for you, even if you use the Force parameter.



RELATED LINKS