[{"data":1,"prerenderedAt":2196},["ShallowReactive",2],{"doc-\u002Fexamples\u002Fpython-folder-size-calculator-example":3},{"id":4,"title":5,"body":6,"description":2189,"extension":2190,"meta":2191,"navigation":52,"path":2192,"seo":2193,"stem":2194,"__hash__":2195},"content\u002Fexamples\u002Fpython-folder-size-calculator-example.md","Python Folder Size Calculator Example",{"type":7,"value":8,"toc":2156},"minimark",[9,13,22,25,241,244,249,252,279,282,286,289,306,314,318,321,482,487,513,520,523,526,558,561,592,599,603,611,615,621,785,789,817,820,824,827,1204,1207,1213,1216,1220,1223,1240,1244,1250,1253,1315,1322,1329,1333,1339,1344,1348,1353,1356,1440,1452,1459,1464,1470,1569,1573,1579,1582,1773,1780,1784,1787,1882,1886,1889,1906,1909,2068,2071,2075,2079,2085,2089,2092,2096,2101,2105,2111,2115,2149,2152],[10,11,5],"h1",{"id":12},"python-folder-size-calculator-example",[14,15,16,17,21],"p",{},"Build a simple Python script that calculates the total size of files inside a folder. This example helps beginners practice working with file paths, loops, and the ",[18,19,20],"code",{},"os"," module.",[14,23,24],{},"If you want the shortest working version first, start here:",[26,27,32],"pre",{"className":28,"code":29,"language":30,"meta":31,"style":31},"language-python shiki shiki-themes material-theme-lighter github-light github-dark","import os\n\nfolder_path = \".\"\ntotal_size = 0\n\nfor name in os.listdir(folder_path):\n    path = os.path.join(folder_path, name)\n    if os.path.isfile(path):\n        total_size += os.path.getsize(path)\n\nprint(f\"Total size: {total_size} bytes\")\n","python","",[18,33,34,47,54,75,87,92,123,157,180,206,211],{"__ignoreMap":31},[35,36,39,43],"span",{"class":37,"line":38},"line",1,[35,40,42],{"class":41},"sVHd0","import",[35,44,46],{"class":45},"su5hD"," os\n",[35,48,50],{"class":37,"line":49},2,[35,51,53],{"emptyLinePlaceholder":52},true,"\n",[35,55,57,60,64,68,72],{"class":37,"line":56},3,[35,58,59],{"class":45},"folder_path ",[35,61,63],{"class":62},"smGrS","=",[35,65,67],{"class":66},"sjJ54"," \"",[35,69,71],{"class":70},"s_sjI",".",[35,73,74],{"class":66},"\"\n",[35,76,78,81,83],{"class":37,"line":77},4,[35,79,80],{"class":45},"total_size ",[35,82,63],{"class":62},[35,84,86],{"class":85},"srdBf"," 0\n",[35,88,90],{"class":37,"line":89},5,[35,91,53],{"emptyLinePlaceholder":52},[35,93,95,98,101,104,107,110,114,117,120],{"class":37,"line":94},6,[35,96,97],{"class":41},"for",[35,99,100],{"class":45}," name ",[35,102,103],{"class":41},"in",[35,105,106],{"class":45}," os",[35,108,71],{"class":109},"sP7_E",[35,111,113],{"class":112},"slqww","listdir",[35,115,116],{"class":109},"(",[35,118,119],{"class":112},"folder_path",[35,121,122],{"class":109},"):\n",[35,124,126,129,131,133,135,139,141,144,146,148,151,154],{"class":37,"line":125},7,[35,127,128],{"class":45},"    path ",[35,130,63],{"class":62},[35,132,106],{"class":45},[35,134,71],{"class":109},[35,136,138],{"class":137},"skxfh","path",[35,140,71],{"class":109},[35,142,143],{"class":112},"join",[35,145,116],{"class":109},[35,147,119],{"class":112},[35,149,150],{"class":109},",",[35,152,153],{"class":112}," name",[35,155,156],{"class":109},")\n",[35,158,160,163,165,167,169,171,174,176,178],{"class":37,"line":159},8,[35,161,162],{"class":41},"    if",[35,164,106],{"class":45},[35,166,71],{"class":109},[35,168,138],{"class":137},[35,170,71],{"class":109},[35,172,173],{"class":112},"isfile",[35,175,116],{"class":109},[35,177,138],{"class":112},[35,179,122],{"class":109},[35,181,183,186,189,191,193,195,197,200,202,204],{"class":37,"line":182},9,[35,184,185],{"class":45},"        total_size ",[35,187,188],{"class":62},"+=",[35,190,106],{"class":45},[35,192,71],{"class":109},[35,194,138],{"class":137},[35,196,71],{"class":109},[35,198,199],{"class":112},"getsize",[35,201,116],{"class":109},[35,203,138],{"class":112},[35,205,156],{"class":109},[35,207,209],{"class":37,"line":208},10,[35,210,53],{"emptyLinePlaceholder":52},[35,212,214,218,220,224,227,230,233,236,239],{"class":37,"line":213},11,[35,215,217],{"class":216},"sptTA","print",[35,219,116],{"class":109},[35,221,223],{"class":222},"sbsja","f",[35,225,226],{"class":70},"\"Total size: ",[35,228,229],{"class":85},"{",[35,231,232],{"class":112},"total_size",[35,234,235],{"class":85},"}",[35,237,238],{"class":70}," bytes\"",[35,240,156],{"class":109},[14,242,243],{},"This quick version adds the size of files in one folder only. A later section expands it to include subfolders.",[245,246,248],"h2",{"id":247},"what-this-example-does","What this example does",[14,250,251],{},"This example shows how to:",[253,254,255,259,273,276],"ul",{},[256,257,258],"li",{},"Calculate the total size of files in a folder",[256,260,261,262,265,266,269,270],{},"Combine ",[18,263,264],{},"os.listdir()",", ",[18,267,268],{},"os.path.join()",", and ",[18,271,272],{},"os.path.getsize()",[256,274,275],{},"Understand how file system paths work in Python",[256,277,278],{},"Solve one practical task with a small script",[14,280,281],{},"This is a good beginner project because it uses a loop, file paths, and built-in standard library tools in one place.",[245,283,285],{"id":284},"what-you-need-to-know-first","What you need to know first",[14,287,288],{},"Before reading the code, it helps to understand a few basics:",[253,290,291,294,297,303],{},[256,292,293],{},"A folder can contain files and subfolders",[256,295,296],{},"A file path tells Python where a file or folder is",[256,298,299,300,302],{},"The ",[18,301,20],{}," module gives you tools for working with files and folders",[256,304,305],{},"A loop lets you process items one by one",[14,307,308,309,71],{},"If file paths still feel confusing, see ",[310,311,313],"a",{"href":312},"\u002Flearn\u002Fworking-with-file-paths-in-python\u002F","working with file paths in Python",[245,315,317],{"id":316},"simple-version-total-size-of-files-in-one-folder","Simple version: total size of files in one folder",[14,319,320],{},"This version checks one folder only. It does not go inside subfolders.",[26,322,324],{"className":28,"code":323,"language":30,"meta":31,"style":31},"import os\n\nfolder_path = \".\"\n\ntotal_size = 0\n\nfor name in os.listdir(folder_path):\n    path = os.path.join(folder_path, name)\n\n    if os.path.isfile(path):\n        total_size += os.path.getsize(path)\n\nprint(f\"Total size: {total_size} bytes\")\n",[18,325,326,332,336,348,352,360,364,384,410,414,434,456,461],{"__ignoreMap":31},[35,327,328,330],{"class":37,"line":38},[35,329,42],{"class":41},[35,331,46],{"class":45},[35,333,334],{"class":37,"line":49},[35,335,53],{"emptyLinePlaceholder":52},[35,337,338,340,342,344,346],{"class":37,"line":56},[35,339,59],{"class":45},[35,341,63],{"class":62},[35,343,67],{"class":66},[35,345,71],{"class":70},[35,347,74],{"class":66},[35,349,350],{"class":37,"line":77},[35,351,53],{"emptyLinePlaceholder":52},[35,353,354,356,358],{"class":37,"line":89},[35,355,80],{"class":45},[35,357,63],{"class":62},[35,359,86],{"class":85},[35,361,362],{"class":37,"line":94},[35,363,53],{"emptyLinePlaceholder":52},[35,365,366,368,370,372,374,376,378,380,382],{"class":37,"line":125},[35,367,97],{"class":41},[35,369,100],{"class":45},[35,371,103],{"class":41},[35,373,106],{"class":45},[35,375,71],{"class":109},[35,377,113],{"class":112},[35,379,116],{"class":109},[35,381,119],{"class":112},[35,383,122],{"class":109},[35,385,386,388,390,392,394,396,398,400,402,404,406,408],{"class":37,"line":159},[35,387,128],{"class":45},[35,389,63],{"class":62},[35,391,106],{"class":45},[35,393,71],{"class":109},[35,395,138],{"class":137},[35,397,71],{"class":109},[35,399,143],{"class":112},[35,401,116],{"class":109},[35,403,119],{"class":112},[35,405,150],{"class":109},[35,407,153],{"class":112},[35,409,156],{"class":109},[35,411,412],{"class":37,"line":182},[35,413,53],{"emptyLinePlaceholder":52},[35,415,416,418,420,422,424,426,428,430,432],{"class":37,"line":208},[35,417,162],{"class":41},[35,419,106],{"class":45},[35,421,71],{"class":109},[35,423,138],{"class":137},[35,425,71],{"class":109},[35,427,173],{"class":112},[35,429,116],{"class":109},[35,431,138],{"class":112},[35,433,122],{"class":109},[35,435,436,438,440,442,444,446,448,450,452,454],{"class":37,"line":213},[35,437,185],{"class":45},[35,439,188],{"class":62},[35,441,106],{"class":45},[35,443,71],{"class":109},[35,445,138],{"class":137},[35,447,71],{"class":109},[35,449,199],{"class":112},[35,451,116],{"class":109},[35,453,138],{"class":112},[35,455,156],{"class":109},[35,457,459],{"class":37,"line":458},12,[35,460,53],{"emptyLinePlaceholder":52},[35,462,464,466,468,470,472,474,476,478,480],{"class":37,"line":463},13,[35,465,217],{"class":216},[35,467,116],{"class":109},[35,469,223],{"class":222},[35,471,226],{"class":70},[35,473,229],{"class":85},[35,475,232],{"class":112},[35,477,235],{"class":85},[35,479,238],{"class":70},[35,481,156],{"class":109},[483,484,486],"h3",{"id":485},"how-it-works","How it works",[253,488,489,495,501,507],{},[256,490,491,494],{},[18,492,493],{},"os.listdir(folder_path)"," gets the names of items in the folder",[256,496,497,500],{},[18,498,499],{},"os.path.join(folder_path, name)"," builds the full path",[256,502,503,506],{},[18,504,505],{},"os.path.isfile(path)"," checks whether the item is a file",[256,508,509,512],{},[18,510,511],{},"os.path.getsize(path)"," gets the file size in bytes",[483,514,516,517,519],{"id":515},"why-ospathjoin-matters","Why ",[18,518,268],{}," matters",[14,521,522],{},"Do not build paths by hand with string addition. This can break on different operating systems.",[14,524,525],{},"Good:",[26,527,529],{"className":28,"code":528,"language":30,"meta":31,"style":31},"path = os.path.join(folder_path, name)\n",[18,530,531],{"__ignoreMap":31},[35,532,533,536,538,540,542,544,546,548,550,552,554,556],{"class":37,"line":38},[35,534,535],{"class":45},"path ",[35,537,63],{"class":62},[35,539,106],{"class":45},[35,541,71],{"class":109},[35,543,138],{"class":137},[35,545,71],{"class":109},[35,547,143],{"class":112},[35,549,116],{"class":109},[35,551,119],{"class":112},[35,553,150],{"class":109},[35,555,153],{"class":112},[35,557,156],{"class":109},[14,559,560],{},"Less reliable:",[26,562,564],{"className":28,"code":563,"language":30,"meta":31,"style":31},"path = folder_path + \"\u002F\" + name\n",[18,565,566],{"__ignoreMap":31},[35,567,568,570,572,575,578,580,583,586,589],{"class":37,"line":38},[35,569,535],{"class":45},[35,571,63],{"class":62},[35,573,574],{"class":45}," folder_path ",[35,576,577],{"class":62},"+",[35,579,67],{"class":66},[35,581,582],{"class":70},"\u002F",[35,584,585],{"class":66},"\"",[35,587,588],{"class":62}," +",[35,590,591],{"class":45}," name\n",[14,593,594,595,71],{},"If you want a deeper explanation, see ",[310,596,598],{"href":597},"\u002Fstandard-library\u002Fos.path.join-function-explained","os.path.join() explained",[483,600,602],{"id":601},"example-output","Example output",[26,604,609],{"className":605,"code":607,"language":608,"meta":31},[606],"language-text","Total size: 15432 bytes\n","text",[18,610,607],{"__ignoreMap":31},[245,612,614],{"id":613},"recursive-version-include-subfolders","Recursive version: include subfolders",[14,616,617,618,71],{},"The basic version only counts files in the current folder. If you want the total size of a folder and everything inside it, including subfolders, use ",[18,619,620],{},"os.walk()",[26,622,624],{"className":28,"code":623,"language":30,"meta":31,"style":31},"import os\n\nfolder_path = \".\"\n\ntotal_size = 0\n\nfor root, dirs, files in os.walk(folder_path):\n    for name in files:\n        path = os.path.join(root, name)\n        total_size += os.path.getsize(path)\n\nprint(f\"Total size: {total_size} bytes\")\n",[18,625,626,632,636,648,652,660,664,696,711,739,761,765],{"__ignoreMap":31},[35,627,628,630],{"class":37,"line":38},[35,629,42],{"class":41},[35,631,46],{"class":45},[35,633,634],{"class":37,"line":49},[35,635,53],{"emptyLinePlaceholder":52},[35,637,638,640,642,644,646],{"class":37,"line":56},[35,639,59],{"class":45},[35,641,63],{"class":62},[35,643,67],{"class":66},[35,645,71],{"class":70},[35,647,74],{"class":66},[35,649,650],{"class":37,"line":77},[35,651,53],{"emptyLinePlaceholder":52},[35,653,654,656,658],{"class":37,"line":89},[35,655,80],{"class":45},[35,657,63],{"class":62},[35,659,86],{"class":85},[35,661,662],{"class":37,"line":94},[35,663,53],{"emptyLinePlaceholder":52},[35,665,666,668,671,673,676,678,681,683,685,687,690,692,694],{"class":37,"line":125},[35,667,97],{"class":41},[35,669,670],{"class":45}," root",[35,672,150],{"class":109},[35,674,675],{"class":45}," dirs",[35,677,150],{"class":109},[35,679,680],{"class":45}," files ",[35,682,103],{"class":41},[35,684,106],{"class":45},[35,686,71],{"class":109},[35,688,689],{"class":112},"walk",[35,691,116],{"class":109},[35,693,119],{"class":112},[35,695,122],{"class":109},[35,697,698,701,703,705,708],{"class":37,"line":159},[35,699,700],{"class":41},"    for",[35,702,100],{"class":45},[35,704,103],{"class":41},[35,706,707],{"class":45}," files",[35,709,710],{"class":109},":\n",[35,712,713,716,718,720,722,724,726,728,730,733,735,737],{"class":37,"line":182},[35,714,715],{"class":45},"        path ",[35,717,63],{"class":62},[35,719,106],{"class":45},[35,721,71],{"class":109},[35,723,138],{"class":137},[35,725,71],{"class":109},[35,727,143],{"class":112},[35,729,116],{"class":109},[35,731,732],{"class":112},"root",[35,734,150],{"class":109},[35,736,153],{"class":112},[35,738,156],{"class":109},[35,740,741,743,745,747,749,751,753,755,757,759],{"class":37,"line":208},[35,742,185],{"class":45},[35,744,188],{"class":62},[35,746,106],{"class":45},[35,748,71],{"class":109},[35,750,138],{"class":137},[35,752,71],{"class":109},[35,754,199],{"class":112},[35,756,116],{"class":109},[35,758,138],{"class":112},[35,760,156],{"class":109},[35,762,763],{"class":37,"line":213},[35,764,53],{"emptyLinePlaceholder":52},[35,766,767,769,771,773,775,777,779,781,783],{"class":37,"line":458},[35,768,217],{"class":216},[35,770,116],{"class":109},[35,772,223],{"class":222},[35,774,226],{"class":70},[35,776,229],{"class":85},[35,778,232],{"class":112},[35,780,235],{"class":85},[35,782,238],{"class":70},[35,784,156],{"class":109},[483,786,788],{"id":787},"how-this-version-works","How this version works",[253,790,791,797,802,808,814],{},[256,792,793,796],{},[18,794,795],{},"os.walk(folder_path)"," goes through the folder and all subfolders",[256,798,799,801],{},[18,800,732],{}," is the current folder being processed",[256,803,804,807],{},[18,805,806],{},"files"," is a list of file names in that folder",[256,809,810,811],{},"Each file path is built with ",[18,812,813],{},"os.path.join(root, name)",[256,815,816],{},"The script adds the size of every file it finds",[14,818,819],{},"This version is usually more useful for real folder size checks.",[245,821,823],{"id":822},"show-the-size-in-a-readable-format","Show the size in a readable format",[14,825,826],{},"File sizes in bytes are correct, but they are not always easy to read. You can add a helper function to show sizes in KB, MB, or GB.",[26,828,830],{"className":28,"code":829,"language":30,"meta":31,"style":31},"import os\n\ndef format_size(size_in_bytes):\n    units = [\"bytes\", \"KB\", \"MB\", \"GB\", \"TB\"]\n    size = float(size_in_bytes)\n\n    for unit in units:\n        if size \u003C 1024 or unit == units[-1]:\n            return f\"{size:.2f} {unit}\"\n        size \u002F= 1024\n\nfolder_path = \".\"\ntotal_size = 0\n\nfor root, dirs, files in os.walk(folder_path):\n    for name in files:\n        path = os.path.join(root, name)\n        total_size += os.path.getsize(path)\n\nprint(f\"Folder: {folder_path}\")\nprint(f\"Total size: {format_size(total_size)}\")\n",[18,831,832,838,842,859,915,932,936,950,986,1016,1027,1031,1043,1051,1056,1085,1098,1125,1148,1153,1175],{"__ignoreMap":31},[35,833,834,836],{"class":37,"line":38},[35,835,42],{"class":41},[35,837,46],{"class":45},[35,839,840],{"class":37,"line":49},[35,841,53],{"emptyLinePlaceholder":52},[35,843,844,847,851,853,857],{"class":37,"line":56},[35,845,846],{"class":222},"def",[35,848,850],{"class":849},"sGLFI"," format_size",[35,852,116],{"class":109},[35,854,856],{"class":855},"sFwrP","size_in_bytes",[35,858,122],{"class":109},[35,860,861,864,866,869,871,874,876,878,880,883,885,887,889,892,894,896,898,901,903,905,907,910,912],{"class":37,"line":77},[35,862,863],{"class":45},"    units ",[35,865,63],{"class":62},[35,867,868],{"class":109}," [",[35,870,585],{"class":66},[35,872,873],{"class":70},"bytes",[35,875,585],{"class":66},[35,877,150],{"class":109},[35,879,67],{"class":66},[35,881,882],{"class":70},"KB",[35,884,585],{"class":66},[35,886,150],{"class":109},[35,888,67],{"class":66},[35,890,891],{"class":70},"MB",[35,893,585],{"class":66},[35,895,150],{"class":109},[35,897,67],{"class":66},[35,899,900],{"class":70},"GB",[35,902,585],{"class":66},[35,904,150],{"class":109},[35,906,67],{"class":66},[35,908,909],{"class":70},"TB",[35,911,585],{"class":66},[35,913,914],{"class":109},"]\n",[35,916,917,920,922,926,928,930],{"class":37,"line":89},[35,918,919],{"class":45},"    size ",[35,921,63],{"class":62},[35,923,925],{"class":924},"sZMiF"," float",[35,927,116],{"class":109},[35,929,856],{"class":112},[35,931,156],{"class":109},[35,933,934],{"class":37,"line":94},[35,935,53],{"emptyLinePlaceholder":52},[35,937,938,940,943,945,948],{"class":37,"line":125},[35,939,700],{"class":41},[35,941,942],{"class":45}," unit ",[35,944,103],{"class":41},[35,946,947],{"class":45}," units",[35,949,710],{"class":109},[35,951,952,955,958,961,964,967,969,972,974,977,980,983],{"class":37,"line":159},[35,953,954],{"class":41},"        if",[35,956,957],{"class":45}," size ",[35,959,960],{"class":62},"\u003C",[35,962,963],{"class":85}," 1024",[35,965,966],{"class":62}," or",[35,968,942],{"class":45},[35,970,971],{"class":62},"==",[35,973,947],{"class":45},[35,975,976],{"class":109},"[",[35,978,979],{"class":62},"-",[35,981,982],{"class":85},"1",[35,984,985],{"class":109},"]:\n",[35,987,988,991,994,996,998,1001,1004,1006,1009,1012,1014],{"class":37,"line":182},[35,989,990],{"class":41},"            return",[35,992,993],{"class":222}," f",[35,995,585],{"class":70},[35,997,229],{"class":85},[35,999,1000],{"class":45},"size",[35,1002,1003],{"class":222},":.2f",[35,1005,235],{"class":85},[35,1007,1008],{"class":85}," {",[35,1010,1011],{"class":45},"unit",[35,1013,235],{"class":85},[35,1015,74],{"class":70},[35,1017,1018,1021,1024],{"class":37,"line":208},[35,1019,1020],{"class":45},"        size ",[35,1022,1023],{"class":62},"\u002F=",[35,1025,1026],{"class":85}," 1024\n",[35,1028,1029],{"class":37,"line":213},[35,1030,53],{"emptyLinePlaceholder":52},[35,1032,1033,1035,1037,1039,1041],{"class":37,"line":458},[35,1034,59],{"class":45},[35,1036,63],{"class":62},[35,1038,67],{"class":66},[35,1040,71],{"class":70},[35,1042,74],{"class":66},[35,1044,1045,1047,1049],{"class":37,"line":463},[35,1046,80],{"class":45},[35,1048,63],{"class":62},[35,1050,86],{"class":85},[35,1052,1054],{"class":37,"line":1053},14,[35,1055,53],{"emptyLinePlaceholder":52},[35,1057,1059,1061,1063,1065,1067,1069,1071,1073,1075,1077,1079,1081,1083],{"class":37,"line":1058},15,[35,1060,97],{"class":41},[35,1062,670],{"class":45},[35,1064,150],{"class":109},[35,1066,675],{"class":45},[35,1068,150],{"class":109},[35,1070,680],{"class":45},[35,1072,103],{"class":41},[35,1074,106],{"class":45},[35,1076,71],{"class":109},[35,1078,689],{"class":112},[35,1080,116],{"class":109},[35,1082,119],{"class":112},[35,1084,122],{"class":109},[35,1086,1088,1090,1092,1094,1096],{"class":37,"line":1087},16,[35,1089,700],{"class":41},[35,1091,100],{"class":45},[35,1093,103],{"class":41},[35,1095,707],{"class":45},[35,1097,710],{"class":109},[35,1099,1101,1103,1105,1107,1109,1111,1113,1115,1117,1119,1121,1123],{"class":37,"line":1100},17,[35,1102,715],{"class":45},[35,1104,63],{"class":62},[35,1106,106],{"class":45},[35,1108,71],{"class":109},[35,1110,138],{"class":137},[35,1112,71],{"class":109},[35,1114,143],{"class":112},[35,1116,116],{"class":109},[35,1118,732],{"class":112},[35,1120,150],{"class":109},[35,1122,153],{"class":112},[35,1124,156],{"class":109},[35,1126,1128,1130,1132,1134,1136,1138,1140,1142,1144,1146],{"class":37,"line":1127},18,[35,1129,185],{"class":45},[35,1131,188],{"class":62},[35,1133,106],{"class":45},[35,1135,71],{"class":109},[35,1137,138],{"class":137},[35,1139,71],{"class":109},[35,1141,199],{"class":112},[35,1143,116],{"class":109},[35,1145,138],{"class":112},[35,1147,156],{"class":109},[35,1149,1151],{"class":37,"line":1150},19,[35,1152,53],{"emptyLinePlaceholder":52},[35,1154,1156,1158,1160,1162,1165,1167,1169,1171,1173],{"class":37,"line":1155},20,[35,1157,217],{"class":216},[35,1159,116],{"class":109},[35,1161,223],{"class":222},[35,1163,1164],{"class":70},"\"Folder: ",[35,1166,229],{"class":85},[35,1168,119],{"class":112},[35,1170,235],{"class":85},[35,1172,585],{"class":70},[35,1174,156],{"class":109},[35,1176,1178,1180,1182,1184,1186,1188,1191,1193,1195,1198,1200,1202],{"class":37,"line":1177},21,[35,1179,217],{"class":216},[35,1181,116],{"class":109},[35,1183,223],{"class":222},[35,1185,226],{"class":70},[35,1187,229],{"class":85},[35,1189,1190],{"class":112},"format_size",[35,1192,116],{"class":109},[35,1194,232],{"class":112},[35,1196,1197],{"class":109},")",[35,1199,235],{"class":85},[35,1201,585],{"class":70},[35,1203,156],{"class":109},[483,1205,602],{"id":1206},"example-output-1",[26,1208,1211],{"className":1209,"code":1210,"language":608,"meta":31},[606],"Folder: .\nTotal size: 2.45 MB\n",[18,1212,1210],{"__ignoreMap":31},[14,1214,1215],{},"The helper function keeps the conversion logic separate from the main loop, which makes the script easier to read.",[245,1217,1219],{"id":1218},"common-problems-and-how-to-avoid-them","Common problems and how to avoid them",[14,1221,1222],{},"Here are the most common reasons this script does not work as expected:",[253,1224,1225,1228,1231,1234,1237],{},[256,1226,1227],{},"The folder path is wrong",[256,1229,1230],{},"The script counts only the current folder, not subfolders",[256,1232,1233],{},"File paths are built incorrectly",[256,1235,1236],{},"A permission error blocks access to some files",[256,1238,1239],{},"The output is shown only in bytes when you expected KB or MB",[483,1241,1243],{"id":1242},"_1-the-folder-path-does-not-exist","1. The folder path does not exist",[14,1245,1246,1247,71],{},"If the path is wrong, Python may raise an error such as ",[18,1248,1249],{},"FileNotFoundError",[14,1251,1252],{},"Check the path first:",[26,1254,1256],{"className":28,"code":1255,"language":30,"meta":31,"style":31},"import os\n\nfolder_path = \"my_folder\"\nprint(folder_path)\nprint(os.path.exists(folder_path))\n",[18,1257,1258,1264,1268,1281,1291],{"__ignoreMap":31},[35,1259,1260,1262],{"class":37,"line":38},[35,1261,42],{"class":41},[35,1263,46],{"class":45},[35,1265,1266],{"class":37,"line":49},[35,1267,53],{"emptyLinePlaceholder":52},[35,1269,1270,1272,1274,1276,1279],{"class":37,"line":56},[35,1271,59],{"class":45},[35,1273,63],{"class":62},[35,1275,67],{"class":66},[35,1277,1278],{"class":70},"my_folder",[35,1280,74],{"class":66},[35,1282,1283,1285,1287,1289],{"class":37,"line":77},[35,1284,217],{"class":216},[35,1286,116],{"class":109},[35,1288,119],{"class":112},[35,1290,156],{"class":109},[35,1292,1293,1295,1297,1299,1301,1303,1305,1308,1310,1312],{"class":37,"line":89},[35,1294,217],{"class":216},[35,1296,116],{"class":109},[35,1298,20],{"class":112},[35,1300,71],{"class":109},[35,1302,138],{"class":137},[35,1304,71],{"class":109},[35,1306,1307],{"class":112},"exists",[35,1309,116],{"class":109},[35,1311,119],{"class":112},[35,1313,1314],{"class":109},"))\n",[14,1316,1317,1318,1321],{},"If ",[18,1319,1320],{},"False"," is printed, the path is not valid from the script's current location.",[14,1323,1324,1325,71],{},"For help with this error, see ",[310,1326,1328],{"href":1327},"\u002Ferrors\u002Ffilenotfounderror-errno-2-no-such-file-or-directory-fix\u002F","how to fix FileNotFoundError: Errno 2 No such file or directory",[483,1330,1332],{"id":1331},"_2-you-expected-subfolders-to-be-included","2. You expected subfolders to be included",[14,1334,1335,1336,1338],{},"This is a very common mistake. The ",[18,1337,264],{}," version only checks one folder level.",[14,1340,1341,1342,71],{},"If you want subfolders too, switch to ",[18,1343,620],{},[483,1345,1347],{"id":1346},"_3-paths-are-built-incorrectly","3. Paths are built incorrectly",[14,1349,1350,1351,71],{},"Always combine paths with ",[18,1352,268],{},[14,1354,1355],{},"You can debug by printing the path:",[26,1357,1359],{"className":28,"code":1358,"language":30,"meta":31,"style":31},"import os\n\nfolder_path = \".\"\nfor name in os.listdir(folder_path):\n    path = os.path.join(folder_path, name)\n    print(path)\n",[18,1360,1361,1367,1371,1383,1403,1429],{"__ignoreMap":31},[35,1362,1363,1365],{"class":37,"line":38},[35,1364,42],{"class":41},[35,1366,46],{"class":45},[35,1368,1369],{"class":37,"line":49},[35,1370,53],{"emptyLinePlaceholder":52},[35,1372,1373,1375,1377,1379,1381],{"class":37,"line":56},[35,1374,59],{"class":45},[35,1376,63],{"class":62},[35,1378,67],{"class":66},[35,1380,71],{"class":70},[35,1382,74],{"class":66},[35,1384,1385,1387,1389,1391,1393,1395,1397,1399,1401],{"class":37,"line":77},[35,1386,97],{"class":41},[35,1388,100],{"class":45},[35,1390,103],{"class":41},[35,1392,106],{"class":45},[35,1394,71],{"class":109},[35,1396,113],{"class":112},[35,1398,116],{"class":109},[35,1400,119],{"class":112},[35,1402,122],{"class":109},[35,1404,1405,1407,1409,1411,1413,1415,1417,1419,1421,1423,1425,1427],{"class":37,"line":89},[35,1406,128],{"class":45},[35,1408,63],{"class":62},[35,1410,106],{"class":45},[35,1412,71],{"class":109},[35,1414,138],{"class":137},[35,1416,71],{"class":109},[35,1418,143],{"class":112},[35,1420,116],{"class":109},[35,1422,119],{"class":112},[35,1424,150],{"class":109},[35,1426,153],{"class":112},[35,1428,156],{"class":109},[35,1430,1431,1434,1436,1438],{"class":37,"line":94},[35,1432,1433],{"class":216},"    print",[35,1435,116],{"class":109},[35,1437,138],{"class":112},[35,1439,156],{"class":109},[14,1441,1442,1443,1447,1448,71],{},"You can also learn more in ",[310,1444,1446],{"href":1445},"\u002Fhow-to\u002Fhow-to-list-files-in-a-directory-in-python\u002F","how to list files in a directory in Python"," and ",[310,1449,1451],{"href":1450},"\u002Fstandard-library\u002Fos.listdir-function-explained","os.listdir() explained",[483,1453,1455,1456],{"id":1454},"_4-a-folder-is-passed-to-getsize","4. A folder is passed to ",[18,1457,1458],{},"getsize()",[14,1460,1461,1463],{},[18,1462,272],{}," works on paths, but in this kind of script you usually want file sizes only.",[14,1465,1466,1467,1469],{},"Check with ",[18,1468,505],{}," first:",[26,1471,1473],{"className":28,"code":1472,"language":30,"meta":31,"style":31},"import os\n\nfolder_path = \".\"\n\nfor name in os.listdir(folder_path):\n    path = os.path.join(folder_path, name)\n    print(os.path.isfile(path))\n",[18,1474,1475,1481,1485,1497,1501,1521,1547],{"__ignoreMap":31},[35,1476,1477,1479],{"class":37,"line":38},[35,1478,42],{"class":41},[35,1480,46],{"class":45},[35,1482,1483],{"class":37,"line":49},[35,1484,53],{"emptyLinePlaceholder":52},[35,1486,1487,1489,1491,1493,1495],{"class":37,"line":56},[35,1488,59],{"class":45},[35,1490,63],{"class":62},[35,1492,67],{"class":66},[35,1494,71],{"class":70},[35,1496,74],{"class":66},[35,1498,1499],{"class":37,"line":77},[35,1500,53],{"emptyLinePlaceholder":52},[35,1502,1503,1505,1507,1509,1511,1513,1515,1517,1519],{"class":37,"line":89},[35,1504,97],{"class":41},[35,1506,100],{"class":45},[35,1508,103],{"class":41},[35,1510,106],{"class":45},[35,1512,71],{"class":109},[35,1514,113],{"class":112},[35,1516,116],{"class":109},[35,1518,119],{"class":112},[35,1520,122],{"class":109},[35,1522,1523,1525,1527,1529,1531,1533,1535,1537,1539,1541,1543,1545],{"class":37,"line":94},[35,1524,128],{"class":45},[35,1526,63],{"class":62},[35,1528,106],{"class":45},[35,1530,71],{"class":109},[35,1532,138],{"class":137},[35,1534,71],{"class":109},[35,1536,143],{"class":112},[35,1538,116],{"class":109},[35,1540,119],{"class":112},[35,1542,150],{"class":109},[35,1544,153],{"class":112},[35,1546,156],{"class":109},[35,1548,1549,1551,1553,1555,1557,1559,1561,1563,1565,1567],{"class":37,"line":125},[35,1550,1433],{"class":216},[35,1552,116],{"class":109},[35,1554,20],{"class":112},[35,1556,71],{"class":109},[35,1558,138],{"class":137},[35,1560,71],{"class":109},[35,1562,173],{"class":112},[35,1564,116],{"class":109},[35,1566,138],{"class":112},[35,1568,1314],{"class":109},[483,1570,1572],{"id":1571},"_5-permission-errors-stop-the-script","5. Permission errors stop the script",[14,1574,1575,1576,71],{},"Some files may not be accessible. In that case, you may get ",[18,1577,1578],{},"PermissionError",[14,1580,1581],{},"A simple way to make the script more robust is to skip files that cannot be read:",[26,1583,1585],{"className":28,"code":1584,"language":30,"meta":31,"style":31},"import os\n\nfolder_path = \".\"\ntotal_size = 0\n\nfor root, dirs, files in os.walk(folder_path):\n    for name in files:\n        path = os.path.join(root, name)\n        try:\n            total_size += os.path.getsize(path)\n        except PermissionError:\n            print(f\"Skipped: {path}\")\n\nprint(f\"Total size: {total_size} bytes\")\n",[18,1586,1587,1593,1597,1609,1617,1621,1649,1661,1687,1694,1717,1727,1749,1753],{"__ignoreMap":31},[35,1588,1589,1591],{"class":37,"line":38},[35,1590,42],{"class":41},[35,1592,46],{"class":45},[35,1594,1595],{"class":37,"line":49},[35,1596,53],{"emptyLinePlaceholder":52},[35,1598,1599,1601,1603,1605,1607],{"class":37,"line":56},[35,1600,59],{"class":45},[35,1602,63],{"class":62},[35,1604,67],{"class":66},[35,1606,71],{"class":70},[35,1608,74],{"class":66},[35,1610,1611,1613,1615],{"class":37,"line":77},[35,1612,80],{"class":45},[35,1614,63],{"class":62},[35,1616,86],{"class":85},[35,1618,1619],{"class":37,"line":89},[35,1620,53],{"emptyLinePlaceholder":52},[35,1622,1623,1625,1627,1629,1631,1633,1635,1637,1639,1641,1643,1645,1647],{"class":37,"line":94},[35,1624,97],{"class":41},[35,1626,670],{"class":45},[35,1628,150],{"class":109},[35,1630,675],{"class":45},[35,1632,150],{"class":109},[35,1634,680],{"class":45},[35,1636,103],{"class":41},[35,1638,106],{"class":45},[35,1640,71],{"class":109},[35,1642,689],{"class":112},[35,1644,116],{"class":109},[35,1646,119],{"class":112},[35,1648,122],{"class":109},[35,1650,1651,1653,1655,1657,1659],{"class":37,"line":125},[35,1652,700],{"class":41},[35,1654,100],{"class":45},[35,1656,103],{"class":41},[35,1658,707],{"class":45},[35,1660,710],{"class":109},[35,1662,1663,1665,1667,1669,1671,1673,1675,1677,1679,1681,1683,1685],{"class":37,"line":159},[35,1664,715],{"class":45},[35,1666,63],{"class":62},[35,1668,106],{"class":45},[35,1670,71],{"class":109},[35,1672,138],{"class":137},[35,1674,71],{"class":109},[35,1676,143],{"class":112},[35,1678,116],{"class":109},[35,1680,732],{"class":112},[35,1682,150],{"class":109},[35,1684,153],{"class":112},[35,1686,156],{"class":109},[35,1688,1689,1692],{"class":37,"line":182},[35,1690,1691],{"class":41},"        try",[35,1693,710],{"class":109},[35,1695,1696,1699,1701,1703,1705,1707,1709,1711,1713,1715],{"class":37,"line":208},[35,1697,1698],{"class":45},"            total_size ",[35,1700,188],{"class":62},[35,1702,106],{"class":45},[35,1704,71],{"class":109},[35,1706,138],{"class":137},[35,1708,71],{"class":109},[35,1710,199],{"class":112},[35,1712,116],{"class":109},[35,1714,138],{"class":112},[35,1716,156],{"class":109},[35,1718,1719,1722,1725],{"class":37,"line":213},[35,1720,1721],{"class":41},"        except",[35,1723,1724],{"class":924}," PermissionError",[35,1726,710],{"class":109},[35,1728,1729,1732,1734,1736,1739,1741,1743,1745,1747],{"class":37,"line":458},[35,1730,1731],{"class":216},"            print",[35,1733,116],{"class":109},[35,1735,223],{"class":222},[35,1737,1738],{"class":70},"\"Skipped: ",[35,1740,229],{"class":85},[35,1742,138],{"class":112},[35,1744,235],{"class":85},[35,1746,585],{"class":70},[35,1748,156],{"class":109},[35,1750,1751],{"class":37,"line":463},[35,1752,53],{"emptyLinePlaceholder":52},[35,1754,1755,1757,1759,1761,1763,1765,1767,1769,1771],{"class":37,"line":1053},[35,1756,217],{"class":216},[35,1758,116],{"class":109},[35,1760,223],{"class":222},[35,1762,226],{"class":70},[35,1764,229],{"class":85},[35,1766,232],{"class":112},[35,1768,235],{"class":85},[35,1770,238],{"class":70},[35,1772,156],{"class":109},[14,1774,1775,1776,71],{},"If this happens often, read ",[310,1777,1779],{"href":1778},"\u002Ferrors\u002Fpermissionerror-errno-13-permission-denied-fix\u002F","how to fix PermissionError: Errno 13 Permission denied",[483,1781,1783],{"id":1782},"helpful-debugging-prints","Helpful debugging prints",[14,1785,1786],{},"When the result looks wrong, these simple checks can help:",[26,1788,1790],{"className":28,"code":1789,"language":30,"meta":31,"style":31},"print(folder_path)\nprint(os.path.exists(folder_path))\nprint(os.path.isfile(path))\nprint(os.path.getsize(path))\nprint(root, files)\n",[18,1791,1792,1802,1824,1846,1868],{"__ignoreMap":31},[35,1793,1794,1796,1798,1800],{"class":37,"line":38},[35,1795,217],{"class":216},[35,1797,116],{"class":109},[35,1799,119],{"class":112},[35,1801,156],{"class":109},[35,1803,1804,1806,1808,1810,1812,1814,1816,1818,1820,1822],{"class":37,"line":49},[35,1805,217],{"class":216},[35,1807,116],{"class":109},[35,1809,20],{"class":112},[35,1811,71],{"class":109},[35,1813,138],{"class":137},[35,1815,71],{"class":109},[35,1817,1307],{"class":112},[35,1819,116],{"class":109},[35,1821,119],{"class":112},[35,1823,1314],{"class":109},[35,1825,1826,1828,1830,1832,1834,1836,1838,1840,1842,1844],{"class":37,"line":56},[35,1827,217],{"class":216},[35,1829,116],{"class":109},[35,1831,20],{"class":112},[35,1833,71],{"class":109},[35,1835,138],{"class":137},[35,1837,71],{"class":109},[35,1839,173],{"class":112},[35,1841,116],{"class":109},[35,1843,138],{"class":112},[35,1845,1314],{"class":109},[35,1847,1848,1850,1852,1854,1856,1858,1860,1862,1864,1866],{"class":37,"line":77},[35,1849,217],{"class":216},[35,1851,116],{"class":109},[35,1853,20],{"class":112},[35,1855,71],{"class":109},[35,1857,138],{"class":137},[35,1859,71],{"class":109},[35,1861,199],{"class":112},[35,1863,116],{"class":109},[35,1865,138],{"class":112},[35,1867,1314],{"class":109},[35,1869,1870,1872,1874,1876,1878,1880],{"class":37,"line":89},[35,1871,217],{"class":216},[35,1873,116],{"class":109},[35,1875,732],{"class":112},[35,1877,150],{"class":109},[35,1879,707],{"class":112},[35,1881,156],{"class":109},[245,1883,1885],{"id":1884},"ways-to-improve-the-script","Ways to improve the script",[14,1887,1888],{},"Once the basic version works, you can extend it in useful ways:",[253,1890,1891,1897,1900,1903],{},[256,1892,1893,1894],{},"Ask the user for a folder path with ",[18,1895,1896],{},"input()",[256,1898,1899],{},"Skip hidden files if needed",[256,1901,1902],{},"Show the largest files in the folder",[256,1904,1905],{},"Print separate totals for each subfolder",[14,1907,1908],{},"Here is one simple improvement that lets the user choose the folder:",[26,1910,1912],{"className":28,"code":1911,"language":30,"meta":31,"style":31},"import os\n\nfolder_path = input(\"Enter a folder path: \")\ntotal_size = 0\n\nfor root, dirs, files in os.walk(folder_path):\n    for name in files:\n        path = os.path.join(root, name)\n        total_size += os.path.getsize(path)\n\nprint(f\"Total size: {total_size} bytes\")\n",[18,1913,1914,1920,1924,1944,1952,1956,1984,1996,2022,2044,2048],{"__ignoreMap":31},[35,1915,1916,1918],{"class":37,"line":38},[35,1917,42],{"class":41},[35,1919,46],{"class":45},[35,1921,1922],{"class":37,"line":49},[35,1923,53],{"emptyLinePlaceholder":52},[35,1925,1926,1928,1930,1933,1935,1937,1940,1942],{"class":37,"line":56},[35,1927,59],{"class":45},[35,1929,63],{"class":62},[35,1931,1932],{"class":216}," input",[35,1934,116],{"class":109},[35,1936,585],{"class":66},[35,1938,1939],{"class":70},"Enter a folder path: ",[35,1941,585],{"class":66},[35,1943,156],{"class":109},[35,1945,1946,1948,1950],{"class":37,"line":77},[35,1947,80],{"class":45},[35,1949,63],{"class":62},[35,1951,86],{"class":85},[35,1953,1954],{"class":37,"line":89},[35,1955,53],{"emptyLinePlaceholder":52},[35,1957,1958,1960,1962,1964,1966,1968,1970,1972,1974,1976,1978,1980,1982],{"class":37,"line":94},[35,1959,97],{"class":41},[35,1961,670],{"class":45},[35,1963,150],{"class":109},[35,1965,675],{"class":45},[35,1967,150],{"class":109},[35,1969,680],{"class":45},[35,1971,103],{"class":41},[35,1973,106],{"class":45},[35,1975,71],{"class":109},[35,1977,689],{"class":112},[35,1979,116],{"class":109},[35,1981,119],{"class":112},[35,1983,122],{"class":109},[35,1985,1986,1988,1990,1992,1994],{"class":37,"line":125},[35,1987,700],{"class":41},[35,1989,100],{"class":45},[35,1991,103],{"class":41},[35,1993,707],{"class":45},[35,1995,710],{"class":109},[35,1997,1998,2000,2002,2004,2006,2008,2010,2012,2014,2016,2018,2020],{"class":37,"line":159},[35,1999,715],{"class":45},[35,2001,63],{"class":62},[35,2003,106],{"class":45},[35,2005,71],{"class":109},[35,2007,138],{"class":137},[35,2009,71],{"class":109},[35,2011,143],{"class":112},[35,2013,116],{"class":109},[35,2015,732],{"class":112},[35,2017,150],{"class":109},[35,2019,153],{"class":112},[35,2021,156],{"class":109},[35,2023,2024,2026,2028,2030,2032,2034,2036,2038,2040,2042],{"class":37,"line":182},[35,2025,185],{"class":45},[35,2027,188],{"class":62},[35,2029,106],{"class":45},[35,2031,71],{"class":109},[35,2033,138],{"class":137},[35,2035,71],{"class":109},[35,2037,199],{"class":112},[35,2039,116],{"class":109},[35,2041,138],{"class":112},[35,2043,156],{"class":109},[35,2045,2046],{"class":37,"line":208},[35,2047,53],{"emptyLinePlaceholder":52},[35,2049,2050,2052,2054,2056,2058,2060,2062,2064,2066],{"class":37,"line":213},[35,2051,217],{"class":216},[35,2053,116],{"class":109},[35,2055,223],{"class":222},[35,2057,226],{"class":70},[35,2059,229],{"class":85},[35,2061,232],{"class":112},[35,2063,235],{"class":85},[35,2065,238],{"class":70},[35,2067,156],{"class":109},[14,2069,2070],{},"You could also combine this with the readable size function from the earlier section.",[245,2072,2074],{"id":2073},"faq","FAQ",[483,2076,2078],{"id":2077},"does-this-script-include-subfolders","Does this script include subfolders?",[14,2080,2081,2082,2084],{},"The basic version does not. Use a recursive version with ",[18,2083,620],{}," to include subfolders.",[483,2086,2088],{"id":2087},"why-am-i-getting-filenotfounderror","Why am I getting FileNotFoundError?",[14,2090,2091],{},"The path may be wrong, or the current working directory may not be what you expect.",[483,2093,2095],{"id":2094},"why-is-the-size-shown-in-bytes","Why is the size shown in bytes?",[14,2097,2098,2100],{},[18,2099,272],{}," returns bytes. You can convert that value to KB, MB, or GB.",[483,2102,2104],{"id":2103},"can-i-calculate-folder-size-with-pathlib-instead-of-os","Can I calculate folder size with pathlib instead of os?",[14,2106,2107,2108,2110],{},"Yes, but this example keeps things simple by using ",[18,2109,20],{}," tools that many beginners learn first.",[245,2112,2114],{"id":2113},"see-also","See also",[253,2116,2117,2123,2128,2133,2138,2144],{},[256,2118,2119],{},[310,2120,2122],{"href":2121},"\u002Fstandard-library\u002Fpython-os-module-overview\u002F","Python os module overview",[256,2124,2125],{},[310,2126,2127],{"href":1450},"os.listdir() function explained",[256,2129,2130],{},[310,2131,2132],{"href":597},"os.path.join() function explained",[256,2134,2135],{},[310,2136,2137],{"href":1445},"How to list files in a directory in Python",[256,2139,2140],{},[310,2141,2143],{"href":2142},"\u002Fhow-to\u002Fhow-to-check-if-a-file-exists-in-python\u002F","How to check if a file exists in Python",[256,2145,2146],{},[310,2147,2148],{"href":312},"Working with file paths in Python",[14,2150,2151],{},"Try extending this example next by adding subfolder support, readable file sizes, or a report that shows the largest files.",[2153,2154,2155],"style",{},"html pre.shiki code .sVHd0, html code.shiki .sVHd0{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#D73A49;--shiki-default-font-style:inherit;--shiki-dark:#F97583;--shiki-dark-font-style:inherit}html pre.shiki code .su5hD, html code.shiki .su5hD{--shiki-light:#90A4AE;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .smGrS, html code.shiki .smGrS{--shiki-light:#39ADB5;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sjJ54, html code.shiki .sjJ54{--shiki-light:#39ADB5;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .s_sjI, html code.shiki .s_sjI{--shiki-light:#91B859;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .srdBf, html code.shiki .srdBf{--shiki-light:#F76D47;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sP7_E, html code.shiki .sP7_E{--shiki-light:#39ADB5;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .slqww, html code.shiki .slqww{--shiki-light:#6182B8;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .skxfh, html code.shiki .skxfh{--shiki-light:#E53935;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sptTA, html code.shiki .sptTA{--shiki-light:#6182B8;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sbsja, html code.shiki .sbsja{--shiki-light:#9C3EDA;--shiki-default:#D73A49;--shiki-dark:#F97583}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sGLFI, html code.shiki .sGLFI{--shiki-light:#6182B8;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sFwrP, html code.shiki .sFwrP{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#24292E;--shiki-default-font-style:inherit;--shiki-dark:#E1E4E8;--shiki-dark-font-style:inherit}html pre.shiki code .sZMiF, html code.shiki .sZMiF{--shiki-light:#E2931D;--shiki-default:#005CC5;--shiki-dark:#79B8FF}",{"title":31,"searchDepth":49,"depth":49,"links":2157},[2158,2159,2160,2166,2169,2172,2181,2182,2188],{"id":247,"depth":49,"text":248},{"id":284,"depth":49,"text":285},{"id":316,"depth":49,"text":317,"children":2161},[2162,2163,2165],{"id":485,"depth":56,"text":486},{"id":515,"depth":56,"text":2164},"Why os.path.join() matters",{"id":601,"depth":56,"text":602},{"id":613,"depth":49,"text":614,"children":2167},[2168],{"id":787,"depth":56,"text":788},{"id":822,"depth":49,"text":823,"children":2170},[2171],{"id":1206,"depth":56,"text":602},{"id":1218,"depth":49,"text":1219,"children":2173},[2174,2175,2176,2177,2179,2180],{"id":1242,"depth":56,"text":1243},{"id":1331,"depth":56,"text":1332},{"id":1346,"depth":56,"text":1347},{"id":1454,"depth":56,"text":2178},"4. A folder is passed to getsize()",{"id":1571,"depth":56,"text":1572},{"id":1782,"depth":56,"text":1783},{"id":1884,"depth":49,"text":1885},{"id":2073,"depth":49,"text":2074,"children":2183},[2184,2185,2186,2187],{"id":2077,"depth":56,"text":2078},{"id":2087,"depth":56,"text":2088},{"id":2094,"depth":56,"text":2095},{"id":2103,"depth":56,"text":2104},{"id":2113,"depth":49,"text":2114},"Master python folder size calculator example in our comprehensive Python beginner guide.","md",{},"\u002Fexamples\u002Fpython-folder-size-calculator-example",{"title":5,"description":2189},"examples\u002Fpython-folder-size-calculator-example","VHs3RdhFVFlNZ0qjnOI3bQeHpUwqUsqZdctWiZYhbNQ",1777585475130]