set /a countfiles-=%countfiles%
This will set countfiles to 0. I think you want to decrease it by 1, so use this instead:
set /a countfiles-=1
I’m not sure if the for loop will work, better try something like this:
:loop
cscript /nologo c:\deletefile.vbs %BACKUPDIR%
set /a countfiles-=1
if %countfiles% GTR 21 goto loop
Related Contents:
- At which point does `for` or `for /R` enumerate the directory (tree)?
- Iterate all files in a directory using a ‘for’ loop
- How to correct variable overwriting misbehavior when parsing output?
- Batch script with for loop and pipe
- Variables are not behaving as expected
- Single line with multiple commands using Windows batch file
- Batch file to delete files older than N days
- Batch command date and time in file name
- Windows batch: echo without new line
- How to check if a process is running via a batch script
- How do I measure execution time of a command on the Windows command line?
- Windows batch files: .bat vs .cmd?
- ‘Pretty print’ windows %PATH% variable – how to split on ‘;’ in CMD shell
- How to wait all batch files to finish before exiting?
- Trouble with renaming folders and sub folders using Batch
- How to run a PowerShell script without displaying a window?
- How to test if a file is a directory in a batch script?
- Escape percent in bat file
- What does %~d0 mean in a Windows batch file?
- How to verify if a file exists in a batch file?
- Windows command to convert Unix line endings?
- How can I run a program from a batch file without leaving the console open after the program starts?
- Capture output command CMD
- How to run a PowerShell script within a Windows batch file
- Stop and Start a service via batch or cmd file?
- Windows batch file file download from a URL
- How to run batch file from network share without “UNC path are not supported” message?
- Windows Batch File Looping Through Directories to Process Files?
- How can two text files be read in parallel by a batch file?
- Using another language (code page) in a batch file made for others
- How can I debug a .BAT script?
- How to count no of lines in text file and store the value into a variable using batch script?
- Start multiple tasks in parallel and wait for them in windows?
- How do I create a shortcut via command-line in Windows?
- Why does ECHO command print some extra trailing space into the file?
- Running another program in Windows bat file and not create child process
- Kill a Process by Looking up the Port being used by it from a .BAT
- “invalid path 0 files copied” Error while using xcopy command
- Rename all files in a directory with a Windows batch script
- How to echo “2” (no quotes) to a file, from a batch script?
- How to change Screen buffer size in Windows Command Prompt from batch script
- Remove unwanted path name from %path% variable via batch
- How to rename file by replacing substring using batch in Windows [closed]
- echo -e equivalent in Windows?
- Why is the FOR /f loop in this batch script evaluating a blank line?
- Windows Batch: Set Variables from Text File
- Batch file encoding
- batch file Copy files with certain extensions from multiple directories into one directory
- How do you strip quotes out of an ECHO’ed string in a Windows batch file?
- Changing a batch file when its running