To list full pathnames of files in specified path I may use:
FOR /F "tokens=*" %G IN ('DIR /B "path\*.*"') DO echo %~fG
WRONG result: <current_directory>\*.*
ss64.com says: "If a filename with no drive letter/path is expanded to display a drive letter/path the command shell will assume; often incorrectly; that the file resides in the current directory."
This is quite a silly behaviour. However this is probably the problem as DIR here returns a bare filename.
IS THERE ANY WAY TO AVOID SUCH MISTAKE? As it is very easy to make.
I know I can use /S option in DIR command, which makes the result be a full pathname but it also goes through subfolders which is undesired.
Using following syntax everything goes fine but I can't use the advantages of DIR command:
FOR %G IN ("path\*.*") DO echo %~fG
result: <path>\*.*
Do you have any tips or tricks how to work with DIR and full paths?