跳转到内容

文件夹命令

查看文件夹下子文件数(包括子文件夹内的文件数)

文件夹目录输入cmd运行以下命令

cmd
dir /s /b | find /v "" | find /c /v ""

文件夹下的文件夹数量(不包括非文件夹类型的文件数量)

cmd
dir /a:d /b | find /c /v ""

文件夹下的文件数量(包括文件夹数量加文件数量)

cmd
dir /b | find /c /v ""

将文件夹内子文件夹下的文件移动到当前文件夹下

文件夹目录输入PowerShell运行以下命令

PowerShell
# 递归移动所有子文件夹中的文件到上级目录(文件夹1)
Get-ChildItem -Path "H:\文件夹名称" -Recurse -File | Move-Item -Destination "H:\文件夹名称" -Force

查看当前文件夹下,子文件夹的大小

文件夹目录输入PowerShell运行以下命令

PowerShell
Get-ChildItem -Directory | ForEach-Object {
    $size = (Get-ChildItem $_ -Recurse -File | Measure-Object -Property Length -Sum).Sum / 1MB
    Write-Output "$($_.Name): $size MB"
}

运行后即可查看如下:

子文件夹名1: 1139.06792068481 MB

子文件夹名2: 2285.1463394165 MB