{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "4f9ac7c8", "metadata": {}, "outputs": [], "source": [ "import os, sys\n", "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 24, "id": "b82882c0", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\"du -h --max-depth=2 '/mnt/f/娱乐/漫画2/' > /home/whistler/get_size.txt\"" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "path = '/mnt/f/娱乐/漫画2/'\n", "cmd1 = \"du -h --max-depth=2 '%s' > /home/whistler/get_size.txt\" % path\n", "cmd1" ] }, { "cell_type": "code", "execution_count": 25, "id": "9aed57c2", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "os.system(cmd1)" ] }, { "cell_type": "code", "execution_count": 28, "id": "b56342af", "metadata": {}, "outputs": [], "source": [ "ret = pd.read_csv('/home/whistler/get_size.txt', sep='\\t', header=None)" ] }, { "cell_type": "code", "execution_count": 29, "id": "4a975afa", "metadata": {}, "outputs": [], "source": [ "ret[2] = ret[1].apply(lambda x: len(os.listdir(x)))" ] }, { "cell_type": "code", "execution_count": 30, "id": "9081cb0d", "metadata": {}, "outputs": [], "source": [ "ret[3] = ret[0].apply(lambda x: float(x[:-1]) if x[-1] == 'K' else float(x[:-1]) * 1000 if x[-1] == 'M' else float(x[:-1]) * 1000000 if x[-1] == 'G' else float(x)).astype(int)" ] }, { "cell_type": "code", "execution_count": 32, "id": "e35887f7", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
0123
021M/mnt/f/娱乐/漫画2/17h/[17H (蜥臀目)] SKIN · ノーマルミッション...3521000
157M/mnt/f/娱乐/漫画2/17h/[17H (蜥臀目)] SKIN · ノーマルミッション...9657000
241M/mnt/f/娱乐/漫画2/17h/[17H (蜥臀目)] SKIN · ノーマルミッション...5941000
347M/mnt/f/娱乐/漫画2/17h/[17H (蜥臀目)] SKIN · ノーマルミッション...6647000
421M/mnt/f/娱乐/漫画2/17h/[17H (蜥臀目)] 婦警X脅迫X中出し [中国翻訳]2121000
...............
3220103M/mnt/f/娱乐/漫画2/zen/[不紳士作戰部 (ZEN、藺Lyin)] 夏日鉄血調教~...49103000
32211.1G/mnt/f/娱乐/漫画2/zen141100000
32222.0G/mnt/f/娱乐/漫画2/zerodo/[FANBOX] にどDegree123 [中国翻...8792000000
32232.0G/mnt/f/娱乐/漫画2/zerodo12000000
3224194G/mnt/f/娱乐/漫画2/203194000000
\n", "

3225 rows × 4 columns

\n", "
" ], "text/plain": [ " 0 1 2 3\n", "0 21M /mnt/f/娱乐/漫画2/17h/[17H (蜥臀目)] SKIN · ノーマルミッション... 35 21000\n", "1 57M /mnt/f/娱乐/漫画2/17h/[17H (蜥臀目)] SKIN · ノーマルミッション... 96 57000\n", "2 41M /mnt/f/娱乐/漫画2/17h/[17H (蜥臀目)] SKIN · ノーマルミッション... 59 41000\n", "3 47M /mnt/f/娱乐/漫画2/17h/[17H (蜥臀目)] SKIN · ノーマルミッション... 66 47000\n", "4 21M /mnt/f/娱乐/漫画2/17h/[17H (蜥臀目)] 婦警X脅迫X中出し [中国翻訳] 21 21000\n", "... ... ... ... ...\n", "3220 103M /mnt/f/娱乐/漫画2/zen/[不紳士作戰部 (ZEN、藺Lyin)] 夏日鉄血調教~... 49 103000\n", "3221 1.1G /mnt/f/娱乐/漫画2/zen 14 1100000\n", "3222 2.0G /mnt/f/娱乐/漫画2/zerodo/[FANBOX] にどDegree123 [中国翻... 879 2000000\n", "3223 2.0G /mnt/f/娱乐/漫画2/zerodo 1 2000000\n", "3224 194G /mnt/f/娱乐/漫画2/ 203 194000000\n", "\n", "[3225 rows x 4 columns]" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ret" ] }, { "cell_type": "code", "execution_count": 33, "id": "9e2e58ea", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'/mnt/f/娱乐/漫画2/大小统计.csv'" ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "save_path = '%s大小统计.csv' % path\n", "save_path" ] }, { "cell_type": "code", "execution_count": 34, "id": "eca7cfb2", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ret.to_csv(save_path, index=False, header=False)\n", "os.system('rm /home/whistler/get_size.txt')" ] }, { "cell_type": "code", "execution_count": null, "id": "ae6f9d78", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.13" } }, "nbformat": 4, "nbformat_minor": 5 }