Removes empty folders from the supplied path.
Remove-EmptyFolders [-Path] <String> [-Recurse] [-WhatIf] [-Confirm] [<CommonParameters>]
The Remove-EmptyFolders
cmdlet removes all empty folders contained in the
supplied path. By default, only empty folders directly contained in the supplied
path will be removed, but you can optionally remove empty subfolders as well.
Remove-EmptyFolders -Path 'C:\Temp'
Removes any empty folder under C:\Temp
. For example, if C:\Temp\Empty
is an
empty folder, it will be removed. However, if C:\Temp\Sub\Empty
is empty, it
will not be removed.
Remove-EmptyFolders -Path 'C:\Temp' -Recurse
Removes any empty folders under C:\Temp
, including subfolders. For example, if
C:\Temp\Empty
is an empty folder, it will be removed. If C:\Temp\Sub\Empty
is empty, it will also be removed.
The path of a folder in which empty subfolders will be removed.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Indicates that the Remove-EmptyFolders
cmdlet should traverse subfolders to
find all empty folders to remove.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Prompts you for confirmation before running the cmdlet.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.