V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
yvanhe
V2EX  ›  分享创造

删除 kindle 无用文件夹的脚本

  •  
  •   yvanhe ·
    yvanhe · 2016-03-30 22:23:50 +08:00 · 2656 次点击
    这是一个创建于 2962 天前的主题,其中的信息可能已经有所发展或是发生改变。

    今天把 kindle 连到电脑上传 pdf ,看到 documents 文件夹里有个脚本,想起来是我一年前写的,没用过第二次的用来删除没有用的记录文件的脚本……

    kindle 打开文档会在 documents 下建一个文档名.sdr 的文件夹,用来保存打开文件的位置(或者其它我不知道的东西),文档删除之后,这个文件夹还会在,所以写了这个脚本用来删除这些文件夹。

    然而我发现我已经看不懂这个脚本了……我的是kpw+原生系统,据本人测试,是有效的,也不会删除无用.sdr 文件夹之外的内容,可以放心使用,班门弄斧,分享给大家。

    for /d %%i in ('dir *.sdr /a:d /b') do (
    	if not exist %%~ni.mobi if not exist %%~ni.azw if not exist %%~ni.azw3 if not exist %%~ni.txt if not exist %%~ni.pobi rd /s /q %%~ni.sdr
    )
    

    使用方法:kindle 连接电脑后,在 kindle 的 documents 文件夹下新建一个.txt文本文件,把脚本保存在文件里,修改后缀名为.bat ,双击运行就可以了。

    有更好的清理 kindle 的方法,或者有更好的脚本,请务必告诉我。

    第 1 条附言  ·  2016-03-30 23:41:50 +08:00
    for /d %%i in ('dir *.sdr /a:d /b') do (
    if not exist %%~ni.pdf if not exist %%~ni.mobi if not exist %%~ni.azw if not exist %%~ni.azw3 if not exist %%~ni.txt if not exist %%~ni.pobi rd /s /q %%~ni.sdr
    )
    第 2 条附言  ·  2016-03-31 00:01:52 +08:00
    加一条 cd documents ,这样就可以把脚本放在 kindle 根目录了。


    cd documents
    for /d %%i in ('dir *.sdr /a:d /b') do (
    if not exist %%~ni.pdf if not exist %%~ni.mobi if not exist %%~ni.azw if not exist %%~ni.azw3 if not exist %%~ni.txt if not exist %%~ni.pobi rd /s /q %%~ni.sdr
    )
    4 条回复    2016-03-31 00:03:17 +08:00
    yvanhe
        1
    yvanhe  
    OP
       2016-03-30 23:39:06 +08:00 via Android
    噗~传了 pdf 我才想起来 kindle 是原生支持 pdf 的,脚本里忘记检测.pdf 格式文件了,如果还有啥漏的格式,自己照着改就行了,多加一条 if not exist %%~ni.后缀名就行了。
    sarours
        2
    sarours  
       2016-03-30 23:39:19 +08:00 via iPhone
    呃,貌似有个小工具是干这个的, kindle 伴侣里面有介绍
    yvanhe
        3
    yvanhe  
    OP
       2016-03-30 23:57:43 +08:00 via Android
    @sarours 那个还要下个程序,还是脚本方便。
    脚本还有要改进的地方,不能递归删除放在 documents 文件夹里自己建的文件夹中的内容,然而,
    我并不会改(╯‵□′)╯︵┻━┻
    z742364692
        4
    z742364692  
       2016-03-31 00:03:17 +08:00
    加油,今天刚到 kpw ,德亚买的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   6073 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 901ms · UTC 01:48 · PVG 09:48 · LAX 18:48 · JFK 21:48
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.