Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hi 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:






Export file should be like:


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

share|improve this question
Which operating system are you using? It looks like Windows, but which one? – ChrisF Nov 15 '10 at 10:36
up vote 2 down vote accepted

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
share|improve this answer

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


/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.)
share|improve this answer
The OP already stated that they have problems separating by semi-colon so you're giving the same problem again. – Joey Nov 15 '10 at 13:33
@Joey - true, but @rima had 2 problems... one was directories, the other was the semi-colon. Glad you had a solution for that though ;-) – scunliffe Nov 15 '10 at 13:53
I rarely use dir for such tasks nowadays since for is easier to work with (albeit with uglier syntax). Especially true for Unicode file names and the dreaded Raster fonts. – Joey Nov 15 '10 at 14:17
I solve my problem by changing the question, I already create list of files by DIR and read Line by line from oracle.Thanks friends – rima Nov 16 '10 at 5:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .