powershell獲取windows子資料夾的大小
1 $startFolder = "E:\Migration\" 2 $colItems = (Get-ChildItem $startFolder | Where-Object {$_.PSIsContainer -eq $True} | Sort-Object) 3 foreach ($i in $colItems) 4 { 5 $subFolderItems = (Get-ChildItem $i.FullName -recurse | Measure-Object -property length -sum) 6 $FileSize="{0:N2}" -f ($subFolderItems.sum / 1GB) 7 $Unit='GB' 8 if($FileSize -lt 1) 9 { 10 $FileSize="{0:N2}" -f ($subFolderItems.sum / 1MB) 11 $Unit='MB' 12 } 13 write-host $i.FullName ' -- ' $FileSize $Unit -fore green 14 }
計算速度很快,只需修改$startFolder變數即可。
相關推薦
powershell獲取windows子資料夾的大小
1 $startFolder = "E:\Migration\" 2 $colItems = (Get-ChildItem $startFolder | Where-Object {$_.PSIsContainer -eq $True} | Sort-Object) 3 foreach ($i i
powershell獲取windows子文件夾的大小
art measure reac name ont con windows unit sub 1 $startFolder = "E:\Migration\" 2 $colItems = (Get-ChildItem $startFolder | Where-Obje
python_獲取檔案及資料夾大小修改時間
獲取檔案大小 關鍵函式是 os.path.getsize(file) 獲取資料夾大小 沒有直接的函式,但是可以通過遍歷資料夾,將每個檔案的大小疊加 關鍵函式 for root, dirs, files in os.walk(filePath): for f
python win系統獲取磁碟及資料夾大小
獲取磁碟資訊:已使用空間、總空間大小等,python沒有自帶的函式,常用的外掛:WMI python中自帶的有獲取資料夾大小、名稱等資訊的函式:walk() 使用wmi之前的配置 環境: win7、win8 python2.7.7 wmi:1.4.
python獲取檔案及資料夾大小
@1.獲取檔案大小 使用os.path.getsize函式,引數是檔案的路徑。 @2.獲取資料夾大小,即遍歷資料夾,將所有檔案大小加和。遍歷資料夾使用os.walk函式 import os from os.path import join, getsize def ge
Windows開發--獲取檔案大小及獲取資料夾大小的方法
獲取檔案大小 Windows提供了好幾個API函式來獲取檔案大小,還可以使用標準C和標準C++庫函式來獲取(當然了,標準庫函式的底層實現也是呼叫了Windows API函式,效率上可能有所影響)。 const wchar_t* pFile = L"C:\\chromium
用python批量獲取某路徑資料夾及子資料夾下的指定型別檔案,並按原資料夾結構批量儲存處理後的檔案
因為是把自己成功執行的整個程式碼按幾部分截取出來的,所以每一小節程式碼不一定能單獨執行,特此說明。 1.獲取某路徑資料夾及子資料夾下的指定pcm型別檔案的全部路徑 import os def eachfile(filepath): pathdi
javaSE (三十四)File類和遞迴練習(統計資料夾大小、拷貝資料夾、層級列印資料夾、斐波拉契數列、獲取1000階乘全部0和尾部0數目、約瑟夫環)
1、統計資料夾大小: 思路: 套用之前已經做過的,鍵入一個路徑,若有效則封裝成File類 初始化計數器len, 若資料夾下是檔案,則記錄檔案.length() 若資料夾下是資料夾,遞迴 輸出len 注:遞迴也可以刪除資料夾,但是一定要先刪除裡
Python獲取資料夾下的檔案和子資料夾
筆者小白在寫程式碼的時候遇到的這樣的問題,就是說需要根據資料夾的路徑獲取該資料夾下面的所有的檔案和子資料夾。這裡就介紹python的os模組中的兩個函式:os.walk() 、os.listdir()。 os.walk() 該函式的原型是: os.wa
Linux C++獲取資料夾大小
http://www.cnblogs.com/emituofo/p/6225403.html 拿到我們的專案中,卻遇到一些問題:程式中一些讀檔案的程式碼,開始報異常,都不到檔案。這些都是以前沒有遇到過的問題。 到底是什麼情況呢?排查了好久,終於發現使用該文章提供的計算
C#獲取資料夾下的子資料夾
public static List <string> getDirectory(string path) { List<Stri
JAVA之File類 獲取一個目錄下的所有資料夾和檔案,包括子資料夾和子檔案
package ioTest.io3; import java.io.File; /* * 獲取一個目錄下的所有資料夾和檔案,包括子資料夾和子檔案 。 * 並將資料夾和檔名稱列印在控制檯上面。並且要顯示檔案目錄的層級 * 注:運用了遞迴的演算法。 */ public
windows用powershell修改文件/資料夾建立時間、修改時間
用win7自帶的powershell可以輕鬆修改文件/資料夾建立時間、修改時間。而且可以批量修改。 1. 步驟 新建一個bat檔案,在其中新增語句: @ECHO OFF powershel
C#獲取路徑下所有檔案以及子資料夾中檔案
/// <summary> /// 獲取路徑下所有檔案以及子資料夾中檔案 /// </summary> /// <param name="path">全路徑根目錄</param>
檔案基本操作之獲取資料夾下的所有子資料夾及其名稱
獲取資料夾下的所有子資料夾及其名稱: 用到的主要控制元件:TextBox,FolderBrowserDialog,Button,TreeView等。 相關程式碼: private string temStr; Thread thdAddF
MFC獲取資料夾下的所有子資料夾名稱
void FindAllFile(CString strParent) //路徑 遞迴查詢所有檔案 { CString strText_i,str; CFileFind finder; bool bFind=finder.FindFile(strParent + "*.*"); whi
matlab遍歷子資料夾並獲取子資料夾名字以及絕對路徑
資料夾Output下面有output1,output2,output3三個資料夾,每個資料夾下面有若干子資料夾,名字不按順序 for i=1:3 maindir = strcat('/home/jinbeibei/Di-Tech/Output/out
Python將某資料夾及其子資料夾下某種格式的檔案移動到另一個指定的檔案下
import shutil,os new_path='/root/python_test/data/gp_fz' for derName, subfolders, filenames in os.walk('/root/python_test/data/gp'): print(derName
Java與Python統計資料夾及子資料夾下檔案個數
package dang; import java.io.File; /** * @ClassName: FileCount * @Description: TODO() * @author: dangjinhu * @date:
Linux下用ls和du命令檢視檔案以及資料夾大小 (轉載)
ls的用法 ls -l |grep "^-"|wc -l或find ./company -type f | wc -l 檢視某資料夾下檔案的個數,包括子資料夾裡的。 ls -lR|grep "^-"|wc -l 檢視某資料夾下資料夾的個數,包括子資料夾裡的