I have a directory that can contain over a hundred files. I want to create a loop that will go through each file in that directory and ask the user if they want to process the next file or exit the script all together. I can't seem to get the prompt to work inside for the For Loop. Any thoughts would be greatly appreciated.
@echo off Color 1F SetLocal EnableExtensions EnableDelayedExpansion Echo File Processing Screen Echo. :UserPrompt1 Set /p "strContProc=Are you sure you wish to process these files? (Y/N) %=%" If /i "%strContProc%" == "y" ( Goto ProcFiles ) Else If /i "%strContProc%" == "n" ( Goto ProcCancel1 ) Else ( Goto UserPrompt1 ) :ProcFiles If exist "%userprofile%\Desktop\PCExport\Disable" ( Set /a numTotFile = 0 Set /a numFileCount = 0 For /r %%f in (*.txt) do ( Set /a numTotFile += 1 ) ) ELSE ( Goto DirNotFound ) If %numTotFile% EQU 0 ( Goto NoFilesFound ) ELSE If %numTotFile% EQU 1 ( Echo Processing file !numFileCount! of %numTotFile%... Goto EndProc ) ELSE ( Echo. Echo %numTotFile% Files will now be processed. Echo. ) :ReturnProc For /r %%f in (*.txt) do ( Set /a numFileCount += 1 Echo Processing file !numFileCount! of %numTotFile%. . . Echo. Echo !numFileCount! >> %%f If !numFileCount! EQU %numTotFile% ( Echo !numFileCount! of %numTotFile% files have been processed. Goto EndProc ) :UserPrompt2 Set /p "strNextProc=Do you wish to process the next file? (Y/N) %=%" If /i "%strNextProc%" == "y" ( Goto ReturnProc ) Else If /i "%strNextProc%" == "n" ( Goto ProcCancel2 ) Else ( Goto UserPrompt2 ) ) Goto EndProc :DirNotFound Echo The specified processing directory could not be found! Goto EndProc :NoFilesFound Echo Processing cannot continue. There were no export files found to process. Goto EndProc :ProcCancel1 Echo. Echo Processing of files was canceled at the user's request. Goto EndProc :ProcCancel2 Echo. Echo Processing of files was canceled at the user's request. Please make a note of the last file that was processed. Goto EndProc :EndProc EndLocal Echo. Pause