Board logo

标题: [文件操作] 【已解决】如何用批处理删除指定文件夹下的空文件夹和空的xml文件 [打印本页]

作者: ttrrf    时间: 2014-4-2 12:27     标题: 【已解决】如何用批处理删除指定文件夹下的空文件夹和空的xml文件

指定文件夹是:

他的里面有很多的文件夹:

就是这些文件夹下有一些空文件,还有这些文件夹下有一些空的.xml文件。用批处理找到这些空文件夹和空的xml文件。然后将其删除。
谢谢大家帮我 弄一下。
作者: apang    时间: 2014-4-2 12:56

不加参数的rd命令可以删除空文件夹
空的xml文件是指文件大小为0字节,还是指包含空白字符的文件?
作者: ttrrf    时间: 2014-4-2 12:57

回复 2# apang

大小为0字节的
作者: apang    时间: 2014-4-2 13:14

  1. @echo off
  2. pushd "D:\apk_out\"
  3. for /f "delims=" %%a in ('dir /a-d/b/s *.xml') do (
  4.     if "%%~za"=="0" del "%%a"
  5. )
  6. for /f "delims=" %%a in ('dir /ad/b/s^|sort /r') do rd "%%a" 2>nul
  7. pause
复制代码

作者: ttrrf    时间: 2014-4-2 14:47

回复 4# apang
想你学习。。。。感谢,另外有一个plurals.xml,内容为:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <plurals name="uninstall_dialog_title_format">
        <item quantity="other">Uninstall %1$s and %2$d other apps?</item>
        <item quantity="one">Uninstall %s</item>
        <item quantity="two">Uninstall %s and 1 other app?</item>
    </plurals>
    <plurals name="uninstall_result_succeeded">
        <item quantity="other">%1$d apps uninstalled</item>
        <item quantity="one">App uninstalled</item>
    </plurals>
    <plurals name="uninstall_result_failed">
        <item quantity="other">Can't uninstall %1$s and %2$d other apps</item>
        <item quantity="one">"Can't uninstall %s"</item>
        <item quantity="two">"Can't uninstall %s and 1 other app"</item>
    </plurals>
</resources>
我想把添加了红色的部分删除,又如何?拜托了。。。。
作者: wangxiaodong    时间: 2014-4-2 14:58

for /f "delims=" %%a in ('dir /ad/b/s^|sort /r') do rd "%%a" 2>nul是啥意思?4# apang
作者: apang    时间: 2014-4-3 11:36

回复 5# ttrrf


以后与主题不相干的问题请开新贴
  1. findstr /iv "\"other\">Can't" plurals.xml >New.xml
复制代码

作者: apang    时间: 2014-4-3 11:38

回复 6# wangxiaodong


    删除空文件夹
作者: wangxiaodong    时间: 2014-4-3 12:23

貌似不需要用sort/r啊8# apang
作者: ttrrf    时间: 2014-4-4 20:17

回复 7# apang

哦!好的,太感谢你了。谢谢!




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2