I have a bat file 'abc.bat'.
When I will double click it,I want to see all the files
being listed using echo
that were inside those folders. I looked into the SO previous answers and tried to use them but it didn't worked.
My path is:
\\intranet.com\pit\tail\ger\ger\FTP\SMS\2022-05-31
The folder 2022-05-31
has files inside it.I want those list of files outputted when bat file
gets executed.
I tried some solutions:
@echo off
for %%i in (*.*) do echo %%i
Another solution was:
for /r %%i in (\\intranet.com\pit\tail\ger\ger\FTP\SMS\2022-05-31) do echo %%i
But instead of showing files of \\intranet.com\pit\tail\ger\ger\FTP\SMS\2022-05-31
it showed all the files in C:/
drive location
CodePudding user response:
The safest way to do this is to define the network target location as a temporary mapping first, then perform your directory listing.
Example:
@PushD "\\intranet.com\pit\tail\ger\ger\FTP\SMS\2022-05-31" 2>NUL || Exit /B
@Dir /B /A:-D
@Pause
To look up each command, and how it works, please open a Command Prompt window, and type each of the following:
pushd /?
exit /?
dir /?
pause /?
As a side note, you could do it as a one liner:
@PushD "\\intranet.com\pit\tail\ger\ger\FTP\SMS\2022-05-31" 2>NUL && (Dir /B /A:-D & Pause) || Exit /B