FORFILES批处理脚本(摆脱@字符) [英] Forfiles Batch Script (Escaping @ character)

查看:329
本文介绍了FORFILES批处理脚本(摆脱@字符)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个批处理脚本,可以让我删除文件,然后年长一组使用一段时间 FORFILES 。现在,我的目标在打印将被删除的文件。

I'm working on a batch script that will let me delete files older then a set period using forfiles. For now, I'm aiming at printing the files that will be deleted.

该FORFILES调用我用完美的作品从CMD.EXE的外壳,但只要我把它嵌入到一个批处理脚本,它barfs。我怀疑这是由于@字符不被正确逃过一劫,但我不能确定。

The forfiles invocation I'm using works flawlessly from a cmd.exe shell, but as soon as I embed it into a batch script, it barfs. I suspect that this is due to the @ character not being escaped properly, but I'm not certain.

我跑的命令是:

forfiles /S /P "r:\" /m *.bak /d -10 /c "cmd /c echo @PATH"

和它导致以下错误:

ERROR: Invalid argument/option - '@PATH'
Type "FORFILES /?" for usage.

我GOOGLE了所有的地方,并尝试了几种不同的方案为逃避@ PATH组成部分。从 @@ PATH ,一切的 \\@ PATH \\没有结果。

任何帮助将是AP preciated!

Any help would be appreciated!

编辑:我还应该注意到,我立足了很多我从这里 FORFILES知识

I should also note that I'm basing a lot of my knowledge of forfiles from here.

推荐答案

直到我删除周围的目录路径引号,这样我有同样的问题:

I had the same problem until I removed the quotation marks around the directory path , like this:

forfiles /S /P r:\ /m *.bak /d -10 /c "cmd /c echo @PATH"

希望有所帮助。

这篇关于FORFILES批处理脚本(摆脱@字符)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆