Solved

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

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

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now