【问题标题】:Batch file to clean one folder清理一个文件夹的批处理文件
【发布时间】:2023-02-01 15:47:50
【问题描述】:

我的驱动器上有一个文件夹,我会定期清理它。 它只有带有 sql 日志的 txt 文件。 我如何编写批处理脚本来在我运行它时清理它? 我的意思是,我不想去驱动器、查找文件夹等。只是在我的屏幕上有一个快捷方式,它将打开批处理脚本。

我试着自己写,并修改了一下,但它不起作用。

`@echo off
set "search_folder=C:\path\to\folder"
for /f "delims=" %%f in ('dir /b /s /a-d "%search_folder%\*.txt"') do (
  type "%%f" | findstr /v /r "^[ ]*$" > temp.txt
  move /y temp.txt "%%f"
)`

它不会删除任何东西

【问题讨论】:

    标签: batch-file


    【解决方案1】:
    猜你喜欢
    • 1970-01-01
    • 2011-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-06
    • 2010-11-02
    • 2015-01-24
    • 2021-10-10
    相关资源
    最近更新 更多