ansewr the prompt question in batch file with

March 28, 2011 at 05:02:29
Specs: Windows 7
I'm trying to create a patch file to delete the older files that I don't need on my PC
but I get "are you sure (y/n)?
so how can I fore "y" to this question automatically the code is:
f:
cd f:\
forfiles -d -2 -c "cmd /c del @file"

See More: ansewr the prompt question in batch file with

Report •


#1
March 28, 2011 at 06:24:34
DEL only ever asks "Are you sure?" if you tell it to delete all files in a directory. Look over your command. Specifically, make sure your filter isn't picking up directories as well as files.

How To Ask Questions The Smart Way


Report •

#2
March 28, 2011 at 07:27:18
if you mean that I should remove the "@file", I tried it but it didn't work
it gives me "The syntax of the command is incorrect."

Report •

#3
March 28, 2011 at 07:47:25
I was thinking something closer to (untested):
forfiles -d-2 -c"cmd /c if @ISDIR==FALSE del @FILE"

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
March 28, 2011 at 07:56:44
unfortunately it didn't work and didn't give me ant thing

Report •

#5
March 28, 2011 at 08:02:21
It would have had to give you something, unless the -d-2 filter returns nothing, or you're running it in a directory with only other directories. Or some combination of both. the -v switch will help you determine which one it is.

How To Ask Questions The Smart Way


Report •

#6
March 29, 2011 at 01:41:36
yes that's it I didn't know the folders is different
the code I have works on the files without asking but not on the directories.
so the question now how to use this to delete all files and folders without asking if I'm sure to delete.

Report •

#7
March 29, 2011 at 05:05:56
I find a code and it works fine
and ere it is for anyone else needs it
ForFiles /P "xxx" /d -3 /c "CMD /c if @ISDIR==TRUE echo RD /q /s @FILE &RD /q /s @FILE"
note: xxx is the folder path and this will keep 2 days and will delete the older folders
thanks a lot Razor2.3

Report •

Ask Question