Solved

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

Posted on 2009-05-08
4
177 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

763 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