Forum Discussion

jimblye's avatar
jimblye
Copper Contributor
Sep 14, 2023

The where command is broken for directory names containing spaces.

I noticed that if a directory name contains spaces, and the directory is in the PATH, the where command is unable to find anything in that directory.

For example, 7-zip is installed in C:\Program Files\7-zip.
The PATH is "C:\Program Files\7-zip";<rest of path goes here>
I can execute the 7z.exe program from the command line, but the where command will not find it.  For example:
C:\>where 7z
INFO: Could not find files for the given pattern(s).

If I copy it to a directory with a name which does not contain spaces, the where command finds it.

C:\>copy "c:\program files\7-zip\7z.exe" \temp
1 file(s) copied.

C:\>set path=%path%;c:\temp

C:\>where 7z
c:\temp\7z.exe

C:\>ver

Microsoft Windows [Version 10.0.19045.3324]



If I'm wrong, please let me know.  Otherwise, I'm just posting in the hope that Microsoft will find this needle in the haystack of a message and fix the problem.  



  • lmstearn's avatar
    lmstearn
    Brass Contributor

    jimblye 

    Looks broken, yes, does using double quotes in the Path statement make a difference?

    Using quotes gives a result here:

    WHERE "C:\Program Files\7-zip\:7z"

    With 8.3 names:

    WHERE C:\Progra~1\7-zip\:7z 

    WHERE only lists files in the directory level specified, so is pretty restrictive without the /R option.

    HTH ğŸ˜€

Resources