computing
  • 0

Solved Batch – list files only (no path)

  • 0

 

Hi,

I have created a batch files to search for files from an external list.txt. But now I want to generate a list.txt from all the files that are in a directory and subdirectories but without the path.

I have figured out something like this:
DIR (MYPATH) /B/S/A:-D>list.txt

But I get this:
C:Blablagagachachafile.sql
C:Blablagagafoldercode.sql

And I would want just:
file.sql
code.sql

or even better:
file.sql,code.slq,…

The purpose of this batch is to search if files from a specified directory exist in another one.

Thanks for any help,
Julien

 

Share

1 Answer

  1. Doing it with dir could be a bit of a pain. Using the for /r command and for variable substitution makes it easy.


    for /r mydrive:mypathmydir %%g in (*) do echo %%~nxg>>list.txt

    • 0