I've never used batch programming before, my experience is with Java and C#, but I wanted to try to learn. I am trying to make a script so that when I run it, I put in a directory path, and then the program will go through every file in said folder, tell me the name of it and ask if I want to delete it. This is what I have so far:
@ECHO off
set /p folder="Folder Address: "
FOR /R %folder% %%G IN (.) DO (
set filepath=%%~dpa
set /p delete="Delete?: "
IF %delete%="Y" IF %delete%="y"(
del %filepath%
)
pause
)
So when I start the script, it asks for the folder address. I type in C:\Users\Tim\Downloads and press Enter. Then, the command prompt closes and nothing happens. I've been looking into the FOR loop syntax and whatnot, but I still can't find what I'm doing wrong. Any help would be appreciated, thanks!
Edit: I'm pretty sure there are differences in syntax between operating systems. So just in case it's important, I have Windows 7.
Edit: I have updated the code to what npocmaka suggested:
@ECHO off
set /p folder="Folder Address: "
FOR /R %folder% %%G IN (.) DO (
set filepath=%%~dpa
set /p delete="Delete?: "
IF /I !delete!="Y"(
del !filepath!
)
pause
)
It still yields the same results, however.