{"id":312,"date":"2025-08-31T14:41:06","date_gmt":"2025-08-31T07:41:06","guid":{"rendered":"https:\/\/byso.top\/?p=312"},"modified":"2025-08-31T14:41:06","modified_gmt":"2025-08-31T07:41:06","slug":"rclone-%e5%91%bd%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/byso.top\/?p=312","title":{"rendered":"rclone \u547d\u4ee4"},"content":{"rendered":"\n<p>\u57fa\u7840\u67e5\u770b\u547d\u4ee4<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u5217\u51fa\u6587\u4ef6\u548c\u76ee\u5f55<\/h3>\n\n\n\n<p>bash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em># \u5217\u51fa\u6839\u76ee\u5f55\u5185\u5bb9<\/em>\nrclone ls aliyun-drive:\n\n<em># \u5217\u51fa\u7279\u5b9a\u76ee\u5f55\u5185\u5bb9<\/em>\nrclone ls aliyun-drive:\/path\/to\/directory\n\n<em># \u4ee5\u6811\u5f62\u7ed3\u6784\u663e\u793a\uff08\u5e26\u5927\u5c0f\uff09<\/em>\nrclone lsl aliyun-drive:\n\n<em># \u53ea\u663e\u793a\u76ee\u5f55\u7ed3\u6784\uff08\u4e0d\u663e\u793a\u6587\u4ef6\u5927\u5c0f\uff09<\/em>\nrclone lsd aliyun-drive:\n\n<em># \u9012\u5f52\u663e\u793a\u6240\u6709\u6587\u4ef6\uff08\u7c7b\u4f3c ls -la\uff09<\/em>\nrclone lsf aliyun-drive: --format \"tsp\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u6811\u5f62\u67e5\u770b<\/h3>\n\n\n\n<p>bash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em># \u663e\u793a\u76ee\u5f55\u6811\u7ed3\u6784<\/em>\nrclone tree aliyun-drive:\n\n<em># \u9650\u5236\u663e\u793a\u6df1\u5ea6<\/em>\nrclone tree aliyun-drive: --level 2\n\n<em># \u663e\u793a\u6587\u4ef6\u5927\u5c0f<\/em>\nrclone tree aliyun-drive: --size<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u8be6\u7ec6\u4fe1\u606f\u547d\u4ee4<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">3. \u83b7\u53d6\u6587\u4ef6\u8be6\u7ec6\u4fe1\u606f<\/h3>\n\n\n\n<p>bash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em># \u663e\u793a\u6587\u4ef6\/\u76ee\u5f55\u7684\u8be6\u7ec6\u4fe1\u606f<\/em>\nrclone lsjson aliyun-drive:\/path\n\n<em># \u683c\u5f0f\u5316\u8f93\u51fa\u8be6\u7ec6\u4fe1\u606f<\/em>\nrclone lsjson aliyun-drive: --format json | python -m json.tool\n\n<em># \u663e\u793a\u5305\u542b\u5143\u6570\u636e\u7684\u4fe1\u606f<\/em>\nrclone lsjson aliyun-drive: -M<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4. \u7edf\u8ba1\u4fe1\u606f<\/h3>\n\n\n\n<p>bash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em># \u663e\u793a\u5b58\u50a8\u7a7a\u95f4\u4f7f\u7528\u60c5\u51b5<\/em>\nrclone about aliyun-drive:\n\n<em># \u7edf\u8ba1\u6587\u4ef6\u6570\u91cf\u548c\u603b\u5927\u5c0f<\/em>\nrclone size aliyun-drive:\n\n<em># \u68c0\u67e5\u7279\u5b9a\u8def\u5f84<\/em>\nrclone size aliyun-drive:\/Movies<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u9ad8\u7ea7\u67e5\u770b\u547d\u4ee4<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">5. \u641c\u7d22\u6587\u4ef6<\/h3>\n\n\n\n<p>bash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em># \u6309\u6587\u4ef6\u540d\u641c\u7d22<\/em>\nrclone lsf aliyun-drive: --include \"*.mp4\"\n\n<em># \u641c\u7d22\u5305\u542b\u7279\u5b9a\u5173\u952e\u8bcd\u7684\u6587\u4ef6<\/em>\nrclone lsf aliyun-drive: --include \"*movie*\"\n\n<em># \u6392\u9664\u67d0\u4e9b\u6587\u4ef6\u7c7b\u578b<\/em>\nrclone lsf aliyun-drive: --exclude \"*.tmp\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">6. \u5b9e\u65f6\u76d1\u63a7<\/h3>\n\n\n\n<p>bash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em># \u5b9e\u65f6\u67e5\u770b\u67d0\u4e2a\u76ee\u5f55\u7684\u53d8\u5316\uff08\u9700\u8981\u652f\u6301\u7684\u4e91\u76d8\uff09<\/em>\nrclone lsjson aliyun-drive: --poll-interval 10s<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u9488\u5bf9\u4f60\u7684 OpenList \u573a\u666f<\/h2>\n\n\n\n<p>\u5047\u8bbe\u4f60\u7684 rclone \u914d\u7f6e\u540d\u4e3a <code>aliyun-drive<\/code>\uff0c\u4ee5\u4e0b\u662f\u5b9e\u7528\u793a\u4f8b\uff1a<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em># \u67e5\u770b\u963f\u91cc\u4e91\u76d8\u6839\u76ee\u5f55<\/em>\nrclone ls aliyun-drive:\n\n<em># \u67e5\u770b\u89c6\u9891\u6587\u4ef6\u76ee\u5f55<\/em>\nrclone lsl aliyun-drive:\/\u7535\u5f71\nrclone lsl aliyun-drive:\/\u7535\u89c6\u5267\n\n<em># \u641c\u7d22\u6240\u6709\u89c6\u9891\u6587\u4ef6<\/em>\nrclone lsf aliyun-drive: --include \"*.{mp4,mkv,avi,mov}\" -R\n\n<em># \u67e5\u770b\u76ee\u5f55\u6811\u7ed3\u6784<\/em>\nrclone tree aliyun-drive: --level 3\n\n<em># \u83b7\u53d6\u5b58\u50a8\u7a7a\u95f4\u4fe1\u606f<\/em>\nrclone about aliyun-drive:\n\n<em># \u7edf\u8ba1\u89c6\u9891\u6587\u4ef6\u603b\u5927\u5c0f<\/em>\nrclone size aliyun-drive:\/\u7535\u5f71<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u683c\u5f0f\u5316\u8f93\u51fa<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">7. \u81ea\u5b9a\u4e49\u8f93\u51fa\u683c\u5f0f<\/h3>\n\n\n\n<p>bash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em># \u81ea\u5b9a\u4e49\u663e\u793a\u683c\u5f0f\uff1a\u65f6\u95f4\u3001\u5927\u5c0f\u3001\u8def\u5f84<\/em>\nrclone lsf aliyun-drive: --format \"tsp\" -R\n\n<em># \u53ea\u663e\u793a\u6587\u4ef6\u540d<\/em>\nrclone lsf aliyun-drive: --format \"p\"\n\n<em># \u663e\u793a\u4fee\u6539\u65f6\u95f4\u548c\u6587\u4ef6\u540d<\/em>\nrclone lsf aliyun-drive: --format \"tp\"<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9e\u7528\u811a\u672c\u793a\u4f8b<\/h2>\n\n\n\n<p>\u521b\u5efa\u4e00\u4e2a Python \u811a\u672c\u6765\u66f4\u65b9\u4fbf\u5730\u67e5\u770b\u5185\u5bb9\uff1a<\/p>\n\n\n\n<p>python<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>#!\/usr\/bin\/env python3<\/em>\nimport subprocess\nimport json\nimport sys\n\ndef run_rclone_command(cmd):\n    \"\"\"\u6267\u884c rclone \u547d\u4ee4\u5e76\u8fd4\u56de\u7ed3\u679c\"\"\"\n    try:\n        result = subprocess.run(cmd, shell=True, capture_output=True, text=True)\n        if result.returncode == 0:\n            return result.stdout.strip()\n        else:\n            print(f\"\u9519\u8bef: {result.stderr}\")\n            return None\n    except Exception as e:\n        print(f\"\u6267\u884c\u547d\u4ee4\u5931\u8d25: {e}\")\n        return None\n\ndef show_directory_tree(aliyun_drive, path=\"\", level=2):\n    \"\"\"\u663e\u793a\u76ee\u5f55\u6811\"\"\"\n    cmd = f\"rclone tree {aliyun_drive}:{path} --level {level}\"\n    result = run_rclone_command(cmd)\n    if result:\n        print(result)\n\ndef search_videos(aliyun_drive, path=\"\"):\n    \"\"\"\u641c\u7d22\u89c6\u9891\u6587\u4ef6\"\"\"\n    cmd = f\"rclone lsf {aliyun_drive}:{path} --include '*.{{mp4,mkv,avi,mov,rmvb,flv}}' -R\"\n    result = run_rclone_command(cmd)\n    if result:\n        print(\"\u627e\u5230\u7684\u89c6\u9891\u6587\u4ef6:\")\n        for line in result.split('\\n'):\n            if line:\n                print(f\"  {line}\")\n\ndef get_storage_info(aliyun_drive):\n    \"\"\"\u83b7\u53d6\u5b58\u50a8\u4fe1\u606f\"\"\"\n    cmd = f\"rclone about {aliyun_drive}\"\n    result = run_rclone_command(cmd)\n    if result:\n        print(\"\u5b58\u50a8\u7a7a\u95f4\u4fe1\u606f:\")\n        print(result)\n\nif __name__ == \"__main__\":\n    aliyun_drive = \"aliyun-drive\"  <em># \u4f60\u7684 rclone \u914d\u7f6e\u540d<\/em>\n    \n    if len(sys.argv) &gt; 1:\n        if sys.argv&#91;1] == \"tree\":\n            show_directory_tree(aliyun_drive)\n        elif sys.argv&#91;1] == \"videos\":\n            search_videos(aliyun_drive)\n        elif sys.argv&#91;1] == \"info\":\n            get_storage_info(aliyun_drive)\n    else:\n        print(\"\u4f7f\u7528\u65b9\u6cd5:\")\n        print(\"python script.py tree   - \u663e\u793a\u76ee\u5f55\u6811\")\n        print(\"python script.py videos - \u641c\u7d22\u89c6\u9891\u6587\u4ef6\") \n        print(\"python script.py info   - \u663e\u793a\u5b58\u50a8\u4fe1\u606f\")<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5feb\u6377\u522b\u540d\u8bbe\u7f6e<\/h2>\n\n\n\n<p>\u5728 <code>~\/.bashrc<\/code> \u4e2d\u6dfb\u52a0\u4e00\u4e9b\u5feb\u6377\u522b\u540d\uff1a<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em># rclone \u5feb\u6377\u547d\u4ee4<\/em>\nalias rls='rclone ls aliyun-drive:'\nalias rtree='rclone tree aliyun-drive:'\nalias rsize='rclone size aliyun-drive:'\nalias rabout='rclone about aliyun-drive:'\nalias rvideo='rclone lsf aliyun-drive: --include \"*.{mp4,mkv,avi,mov}\" -R'\n\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u57fa\u7840\u67e5\u770b\u547d\u4ee4 1. \u5217\u51fa\u6587\u4ef6\u548c\u76ee\u5f55 bash 2. \u6811\u5f62\u67e5\u770b bash \u8be6\u7ec6\u4fe1\u606f\u547d\u4ee4 3. \u83b7\u53d6\u6587\u4ef6\u8be6\u7ec6\u4fe1\u606f  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-312","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/byso.top\/index.php?rest_route=\/wp\/v2\/posts\/312","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/byso.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/byso.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/byso.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/byso.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=312"}],"version-history":[{"count":1,"href":"https:\/\/byso.top\/index.php?rest_route=\/wp\/v2\/posts\/312\/revisions"}],"predecessor-version":[{"id":313,"href":"https:\/\/byso.top\/index.php?rest_route=\/wp\/v2\/posts\/312\/revisions\/313"}],"wp:attachment":[{"href":"https:\/\/byso.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/byso.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/byso.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}