Export (0) Print
Expand All
Expand Minimize

Converting the FileSystemObject's MoveFolder Method


Windows PowerShell


Definition: Move one or more folders to a different location.

MoveFolder


See Move. You can use the Move-Item cmdlet to move more than one folder, simply use wildcard characters to specify the folders you want. Here’s an example that moves all files and folders beginning with temp from the C:\scripts folder to the C:\old folder:


Move-Item C:\scripts\temp* C:\old


As we mentioned, the preceding example will move all files and folders that begin with temp. If you want to move only folders, check the folder PSIsContainer property. If this property is True, the item in question is a folder. In this example we move only folders beginning with temp from the C:\scripts folder to the C:\old folder:


$c = Get-ChildItem c:\scripts\temp*
foreach($i in $c)
{
    if ($i.PsIsContainer)
    {
        Move-Item $i c:\old
    }
}


See conversions of other FileSystemObject methods and properties.
Return to the VBScript to Windows PowerShell home page

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft