- 1 year ago
forfiles batch command not recognizing + sign when implemented for /d parameter
The forfiles
command in a batch script uses the /d
parameter to specify the date range for selecting files. When using the /d
parameter, you can use the +
sign to specify a date that is older than the specified date.
If the forfiles
command is not recognizing the +
sign when used with the /d
parameter, it may be due to how the batch script handles special characters. In batch scripts, some special characters like +
have a special meaning and need to be escaped or enclosed in double quotes.
To ensure that the +
sign is interpreted correctly in the forfiles
command, you can try one of the following approaches:
Enclose the date value in double quotes:
batchforfiles /d "+mm/dd/yyyy"
Escape the
+
sign with a caret (^
):batchforfiles /d ^+mm/dd/yyyy
By enclosing the date value in double quotes or escaping the +
sign, you can ensure that the forfiles
command recognizes the correct date format.
Keep in mind that the exact syntax may vary depending on the specific usage and requirements of your batch script. Make sure to test and adjust the command according to your specific needs.