You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用ForFiles工具删除3天前的.001扩展名文件时遭遇参数错误,请求帮助

ForFiles工具删除3天前的.001扩展名文件时遭遇参数错误,请求帮助

Hey there! Let's sort out why your ForFiles command is throwing those frustrating errors.

The root of your problem lies in how the command parses the file path and handles quotes. Let's break down what's wrong with your original command:

ForFiles /p "C:\Db2_Backup\" /M *.001 /s /d -3 /c "cmd /c del /q /s @file"

When you use @file, it returns the full path of the file without quotes. If any part of that path has spaces (like folder names with spaces), the del command will misinterpret the path as multiple separate arguments—hence the "Invalid argument/option" errors you're seeing, whether you include /q or not.

Here's the fix:

Use @path instead of @file. The @path variable in ForFiles automatically wraps the full file path in double quotes, which avoids any parsing conflicts with spaces or special characters. Your corrected command will look like this:

ForFiles /p "C:\Db2_Backup\" /M *.001 /s /d -3 /c "cmd /c del /q /s @path"

A quick test tip:

Before running the actual delete command, you can replace del with echo to preview exactly what commands will be executed. This helps you verify everything is targeting the right files without risking accidental deletions:

ForFiles /p "C:\Db2_Backup\" /M *.001 /s /d -3 /c "cmd /c echo del /q /s @path"

Give this a shot—it should resolve those parameter errors and let you delete those old .001 files as intended!

备注:内容来源于stack exchange,提问作者zamir

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.16 10:09:36