V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
hao1032
V2EX  ›  问与答

如何使用 adb 命令清空一个中文文件夹?

  •  
  •   hao1032 · 2016-09-27 20:04:25 +08:00 · 4715 次点击
    这是一个创建于 2739 天前的主题,其中的信息可能已经有所发展或是发生改变。
    假设有如下文件夹 /sdcard/视频 ,视频这个文件夹里面有一些文件或文件夹。怎么使用 adb 命令清空 视频 文件夹呢??
    5 条回复    2016-09-27 20:57:19 +08:00
    noe132
        1
    noe132  
       2016-09-27 20:43:39 +08:00
    adb shell rm -rf /sdcard/视频

    adb shell - run remote shell interactively
    adb shell <command> - run remote shell command
    noe132
        2
    noe132  
       2016-09-27 20:47:18 +08:00
    好像这个编码问题很棘手
    Septembers
        3
    Septembers  
       2016-09-27 20:47:26 +08:00
    @noe132 command 请加引号
    noe132
        4
    noe132  
       2016-09-27 20:57:04 +08:00
    在 windows 环境下,在命令行窗口是 gbk 936 代码页。

    如果手动切换成 chcp 65001 ,就不能用输入法

    实际上这个命令是由 adb 传进去执行的,所以只要保证传进去编码是正确就行

    那么我测试了一下,编辑一个 bat 文件,用 utf-8 编码保存,内容为
    '''
    adb shell "rmdir /sdcard/视频"
    '''
    是可以正常删除文件夹的。尽管在 windows 下命令行窗口里中文显示的是乱码。

    重点是用 utf-8 编码格式保存。
    noe132
        5
    noe132  
       2016-09-27 20:57:19 +08:00
    linux 下应该就不存在编码问题了吧~
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3336 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 13:26 · PVG 21:26 · LAX 06:26 · JFK 09:26
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.