Note, this is in Comment to the posters in a separate thread user619818 and styfle)
DIR can and does allow searching all subdirectories for files matching a specific type.
Note: The Root Directory to check which all subdirectories lie under is assumed to be "C:\My Program\Root\" as the author did not give a path name under which these directories are located
DIR /B /S "C:\My Program\Root\*.ext"
this will give the full file paths and filenames of the source files.
if you only want file names you would have to do as follows
FOR /F "Tokens=*" %A IN ('DIR /B /S "C:\My Program\Root\*.ext"') DO @( Echo.%~nxA )
so assuming you want to move all of these files from "C:\My Program\Root\Sub Directories\*.ext" to "D:\Singlefolder\*.ext" you simply do this:
FOR /F "Tokens=*" %A IN ('DIR /B /S "C:\My Program\Root\*.ext"') DO @( MOVE "%~A" "D:\Singlefolder\%~nxA" /Y )
Hope that helps others in the future. :)
I suspect the answer will be no, but has anyone dealt with this or come up with any way to make this easier?Actually, I’m having the opposite problem, I am trying to figure out a way to get the command-interpreter to treat its list as strings and prevent it from inreptreting them as wildcards. For example,for %i in (foobar baz really?) do @echo %iwill treat the last item (really?) as a filename wildcard, and skip it if there are no files namedreally1,reallyz, etc. ☹ – Synetech Feb 4 '13 at 18:19?is not a legal character for filenames in the Windows filesystem. The character can only be interpreted as a wildcard. See Naming Files, Paths, and Namespaces on MSDN and Using wildcard characters in TechNet. – jww Jul 29 '15 at 4:33