Computing.Net > Forums > Programming > batch file output in table format

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

batch file output in table format

Reply to Message Icon

Name: alwaysk2
Date: August 18, 2008 at 07:35:04 Pacific
OS: Windows 2003 server
CPU/Ram: 8 GHZ / 16 GB DDR2
Product: IBM
Comment:

hi all,

I am making a batch file in which i have a mode where i am comparing total files from source to destination. both source and destinations are on different servers. so i just have used simple dir /b commands to show files on screen. but the problem is there are many files which creates problem while comparing. is there any way by which i can show those files including source and destination in TABLE format?

let me explain giving example like

echo files from source server
dir /b \\server1\logs
echo.
echo files from destination server
dir /b \\server2\<current date>\logs

output comes like:

files from source server
fil1.log
fil1.log
fil1.log
fil1.log
fil1.log

files from destination server
fil1.log
fil1.log
fil1.log
fil1.log
fil1.log

what i want to make is like this
files from source server files from destination server
fil1.log fil1.log
fil1.log fil1.log
fil1.log fil1.log
fil1.log fil1.log
fil1.log fil1.log

is it possible?

K2™
System/Network Engineer



Sponsored Link
Ads by Google

Response Number 1
Name: dtech10
Date: August 18, 2008 at 10:19:15 Pacific
Reply:

Hi alwaysk2

@echo off
for /f %%a in ('dir F1\*.* /b') do (
if exist F2\%%a (
for /f %%b in ('dir F2\%%a /b') do (echo %%a %%b)
) else (echo %%a Not Found)
)


0

Response Number 2
Name: alwaysk2
Date: August 19, 2008 at 07:20:26 Pacific
Reply:

hi dtech,

thanx a lot for your reply.

but the problem is when i am giving this kind of batch file:

=======================
@echo off
for /f %%a in ('dir \\server1\logs\*.* /b') do (
if exist \\server2\<current date>\logs\%%a (
for /f %%b in ('dir \\server2\<current date>\logs\%%a /b') do (echo %%a %%b)
) else (echo %%a Not Found)
)
==============

its having some files (approx 6 files) which have names like 08182008_missing information.log, so this files always shows "FILE NOT FOUND" and the rest files are showing. can you suggest me why it is giving this kind of error or is it related to 8 character DOS names which is generating errors?

K2™
System/Network Engineer


0

Response Number 3
Name: dtech10
Date: August 19, 2008 at 15:07:16 Pacific
Reply:

Hi
Do see why the filename should cause a problem, but try this incase it's to do
with names with spaces in them.

@echo off
for /f "tokens=*" %%a in ('dir F1\*.* /b') do (
if exist F2\"%%a" (
for /f "tokens=*" %%b in ('dir F2\"%%a" /b') do (echo %%a %%b)
) else (echo %%a Not Found)
)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Search and Replace Hide/Unhide Program via S...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: batch file output in table format

Batch File: Integers in a Txt File Variable www.computing.net/answers/programming/batch-file-integers-in-a-txt-file-variable/19900.html

Batch file output formatting www.computing.net/answers/programming/batch-file-output-formatting/15742.html

Batch File-12 hours time format www.computing.net/answers/programming/batch-file12-hours-time-format/16748.html