Mombu the Microsoft Forum sponsored links

Go Back   Mombu the Microsoft Forum > Microsoft > DIR command: how to concat file listing?
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 8th August 00:55
penciline܊xyجr,+&
External User
 
Posts: 1
Default DIR command: how to concat file listing?


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
--
-=- penciline -=-
  Reply With Quote


  sponsored links


2 8th August 00:56
jerold schulman
External User
 
Posts: 1
Default DIR command: how to concat file listing?


@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
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666