Solved

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

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
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 …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

813 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

14 Experts available now in Live!

Get 1:1 Help Now