Re: DIR command: how to concat file listing?
From: Jerold Schulman (Jerry_at_jsiinc.com)
Date: 12/13/04
- Next message: R. C. White: "Re: Windows XP Pro SP2 Defrag cannot continue problem"
- Previous message: Dave Patrick: "Re: Recent Documents list"
- In reply to: penciline: "DIR command: how to concat file listing?"
- Messages sorted by: [ date ] [ thread ]
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
- Next message: R. C. White: "Re: Windows XP Pro SP2 Defrag cannot continue problem"
- Previous message: Dave Patrick: "Re: Recent Documents list"
- In reply to: penciline: "DIR command: how to concat file listing?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|