I have a strange situation and I don't know what is wrong
I need to check if in a directory exist at least one file with a pattern.
IF EXIST d:\*Backup*.* (
ECHO "file exist"
) ELSE (
ECHO "file not exist"
)
If on d:\ I have a file x_Backup.txt
and a folder Backup
I get file exist
but if i have only folder Backup
I get again file exist
, seems that the dot from path is ignored.
Use this; it works with any specific pattern:
There are undocumented wildcards that you can use to achieve this as well.
This wildcard option and other were discussed in length at the following two links. http://www.dostips.com/forum/viewtopic.php?t=6207
http://www.dostips.com/forum/viewtopic.php?f=3&t=5057
From those links:
*.*
is equivalent to*
in dos. It just means 'anything', not anything-period-anything.To check for the directory, try this:
This is another alternative.