Re: DIR command: how to concat file listing?

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Jerold Schulman (Jerry_at_jsiinc.com)
Date: 12/13/04


Date: Mon, 13 Dec 2004 12:07:03 -0500

On Sat, 11 Dec 2004 12:35:02 -0800, penciline <penciline@discussions.microsoft.com> wrote:

>Dear users:
>Does anyone know how to concatinate a file listing from "dir /b" ? I want
>to create a file listing similar to the %PATH% variable which has files
>listed on one line separated by semicolons or commas. In my case I want to
>separate by commas.
>
>Thanks in advance for your help

@echo off
:: First parameter is the folder to dir
if {%1}=={} @echo Syntax: FolderList FolderPath&goto :EOF
if not exist %1 @echo FolderList %1 - %1 not found&goto :EOF
setlocal ENABLEDELAYEDEXPANSION
pushd %1
set LIST=
for /f "Tokens=*" %%a in ('dir /b /a-d') do (
 if "!LIST!" NEQ "" set LIST=!LIST!,
 set LIST=!LIST!%%a
)
@echo %LIST%
endlocal

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com



Relevant Pages

  • DIR command: how to concat file listing?
    ... Does anyone know how to concatinate a file listing from "dir /b"? ... listed on one line separated by semicolons or commas. ... separate by commas. ...
    (microsoft.public.windows.file_system)
  • Re: Entourage Email; Adding Email Addresses Issue
    ... In the annoying little box for entering email addresses, you can separate ... email addresses with commas. ... Author of _Powerful PowerPoint for Educators_ ... When I want to manage the addresses in an email message, Entourage forces me ...
    (microsoft.public.mac.office.entourage)
  • Re: Distinguished Name in AD
    ... a distinguishedname contains commas to separate the different levels in the DN ... Using a LDAP querty tool, we notice that all our users (including new ones ... The backslash is causing the application to quit resolving the DN after the \. ...
    (microsoft.public.windows.server.active_directory)
  • Re: American semicolons
    ... Americans 'only use ";" to separate two things that would otherwise ... individually qualify as full sentences'. ... would normally be separated by commas but contain commas as below. ...
    (alt.usage.english)
  • Re: "Larrabee" GPU design question.
    ... typing lists of numbers separated from each others by commas. ... Even though written reports and spreadsheets insists on me using, ... all my programming languages use US rules. ... semi-columns to separate numbers, I'm not sure whether there is an ...
    (comp.arch)