List filenames in a file with full pathname

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

It seems to be simple, but I don't can find it. I want to produce a filelist with full filenames, lik

c:\documents\file1.xx
c:\documents\file2.xx

if possible from command line (like dir C:\documents /b >FileList.txt)

I don't can find a switch or whatever to add/display the pathname with the filename

Please help. Best regards, Reinhard Franke
 
=?Utf-8?B?UmVpbmhhcmQgRnJhbmtl?= said:
It seems to be simple, but I don't can find it. I want to produce a
filelist with full filenames, like
c:\documents\file1.xxx
c:\documents\file2.xxx

if possible from command line (like dir C:\documents /b >FileList.txt).

I don't can find a switch or whatever to add/display the pathname with
the filename.
Please help. Best regards, Reinhard Franke

Hello Reinhard,

if there are no subfolders or it doesn't matter use also /S. If that's
not possible:

for %A in (C:\documents\file?.*) do @echo %~fA

if you need other dir options (sorting or attr):

for /F "tokens=*" %%A in ('dir C:\documents\file*.* /B') do @echo %~fA

These are for the direct input at the command line, in a batch double
the percent signs.

HTH
 
"if you need other dir options (sorting or attr)
"for /F "tokens=*" %%A in ('dir C:\documents\file*.* /B') do @echo %~fA

Hi Matthias

thanks for the quick responds. The above answer is exactly what I need. But here I get an error info "%%a ist syntaktisch an dieser Stelle nicht verarbeitbar" ("%%a" can't syntactic processed at this place). The same message I get if I write it as batch, with doubled percent signs

Any ideas, Reinhard Frank
 
=?Utf-8?B?UmVpbmhhcmQgRnJhbmtl?= said:
"if you need other dir options (sorting or attr):
"for /F "tokens=*" %%A in ('dir C:\documents\file*.* /B') do @echo %~fA"
Hi Matthias,

thanks for the quick responds. The above answer is exactly what I
need. But here I get an error info "%%a ist syntaktisch an dieser
Stelle nicht verarbeitbar" ("%%a" can't syntactic processed at this
place). The same message I get if I write it as batch, with doubled
percent signs. Any ideas, Reinhard Franke

Sorry, my mistake.
That should be only one percent sign from the command line:
for /F "tokens=*" %A in ('dir C:\documents\file*.* /B') do @echo %~fA

in a batch
@echo offg
for /F "tokens=*" %%A in ('dir C:\documents\file*.* /B') do echo %%~fA

To get details see the help of
For /?

HTH
 
" That should be only one percent sign from the command line
"for /F "tokens=*" %A in ('dir C:\documents\file*.* /B') do @echo %~f

That works, but only for the current path (like a "dir /o /b" command). So I have first to state the drive (for reliability) and a cd command. Will take that as workaround, look under "for /?" for the explanation and play a little bit with it

Thank you, Reinhard Franke
 
Back
Top