hao1032
V2EX  ›  问与答

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

  •  
  •   hao1032 · Sep 27, 2016 · 5431 views
    This topic created in 3551 days ago, the information mentioned may be changed or developed.
    假设有如下文件夹 /sdcard/视频 ,视频这个文件夹里面有一些文件或文件夹。怎么使用 adb 命令清空 视频 文件夹呢??
    5 replies    2016-09-27 20:57:19 +08:00
    noe132
        1
    noe132  
       Sep 27, 2016
    adb shell rm -rf /sdcard/视频

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

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

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

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

    重点是用 utf-8 编码格式保存。
    noe132
        5
    noe132  
       Sep 27, 2016
    linux 下应该就不存在编码问题了吧~
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2614 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 97ms · UTC 14:48 · PVG 22:48 · LAX 07:48 · JFK 10:48
    ♥ Do have faith in what you're doing.