Question: I need a batch file that provides a list of all of my files in my folder that are separated with a ";" in one file.

**Like list of my directory:**

```
dir1
dir2
 a.txt
b.sql
c.html

```

**Export file should be like:**

a.txt;b.sql;c.html

I already use: `dir /a /b /-p /0:gen >list.txt` but it is included directory name & I can not separate them by semi-colon :(

Please help

Answer: 
You can use this simple batch file:

```
@echo off
setlocal enabledelayedexpansion enableextensions
set LIST=
for %%F in (*) do set LIST=!LIST!;%%F
>list.txt echo %LIST:~1%

```

This simply iterates over all files (excluding directories) and appends to a variable which is printed at the end.

A more elaborate way of doing the same with the added benefit that you can cancel it halfway through and still retain the information so far would be

```
@echo off
set FIRST=1
for %%F in (*) do (
  if defined FIRST (
    set FIRST=
    <nul set /P X=%%F
  ) else (
    <nul set /P X=;%%F
  )
)

```
You can use this to just get a basic list... then swap the line breaks for semi-colons

```
dir /A-D /ON /B > list.txt

```

note:

```
/A-D: minus Directories
/ON: Order by Name (not sure if you need this, but typically helpful)
/B: Bare format (e.g. just the names, no dates etc.)

```