Solved

Listing a files/Directories , but i would want in one row

Posted on 2009-05-08
4
178 Views
Last Modified: 2012-05-06
I'm trying listing a directory, but i would want output in one row. could any give me a hand?.

Actually:
dir c:\ /ad /b /-p /o:gen
file1
file2
file2
.
but i want this output: file1 file2 file3....

Thanks in advance
0
Comment
Question by:jpvhack
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 

Expert Comment

by:Brainarts
ID: 24340081
The only way i see to make it is to Output the listing to a file

dir c:\ /ad /b /-p /o:gen > listing.txt

Then Reprocess the file with vba script or any other script to replace the  CRLF line terminator with the file separator you need for example :" ,"

This can be automated very easyly
0
 
LVL 3

Expert Comment

by:SalmanZG
ID: 24340114
If you need to do this for once, do this:

1. dump the out to a text file by appending  "> output.txt" to you dir command.
e.g. dir /b > output.txt

2. Open the file in MS word. Goto find and replace. Replace ^p with a blank/space.

If you need to do it repeatedly - thats another story.

0
 

Author Comment

by:jpvhack
ID: 24340430
It should carry out in a file, in only batch file, or vb script file.

Thanks
0
 
LVL 84

Accepted Solution

by:
oBdA earned 125 total points
ID: 24340832
Save this as LineDir.cmd or Whatever.cmd, and simply pass it the folder to list as first argument:
linedir C:\
@echo off
setlocal enabledelayedexpansion
set Options=/ad /b /-p /o:gen
if "%~1"=="" (echo Syntax: %~nx0 ^<Folder^>&goto :eof)
for /f "delims=" %%a in ('dir %Options% "%~1"') do set Line=!Line! %%a
set Line=%Line:~1%
echo.%Line%

Open in new window

0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question