Need to output the contents of a specific file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
ladduq
Posts: 31
Joined: 22 Jan 2012 01:08

Need to output the contents of a specific file

#1 Post by ladduq » 13 Mar 2012 05:37

Hi,

Need to output the contents of a specific file
Last edited by ladduq on 16 May 2012 04:08, edited 1 time in total.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Need to output the contents of a specific file

#2 Post by foxidrive » 13 Mar 2012 05:51

We'd need to see a sample of the file, and also be told what format you want the output to look like.

ladduq
Posts: 31
Joined: 22 Jan 2012 01:08

Re: Need to output the contents of a specific file

#3 Post by ladduq » 13 Mar 2012 08:02

Hi

we cant see the file contents
Last edited by ladduq on 16 May 2012 04:09, edited 1 time in total.

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Need to output the contents of a specific file

#4 Post by abc0502 » 14 Mar 2012 17:54

Hi,
Why don't you try to open the file with notepad or notepad ++ (if the file big)
if you can read the content and it's not strange symbols let us know and there will be
a possiblity but if it contain symbols then i guess there is no chance without using the original program

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Need to output the contents of a specific file

#5 Post by abc0502 » 14 Mar 2012 18:08

In case that the file can be read from the notepad
try this:

Code: Select all

@echo off
cls
::===> Settings
set file1=%userprofile%\desktop\source.fpr
set file2=%userprofile%\desktop\output.txt
::===> Code
clip < "%file1%"

>"%temp%\clipboard.vbs" (
   echo.Set objHTML = CreateObject("htmlfile"^)
   echo.ClipboardText = objHTML.ParentWindow.ClipboardData.GetData("text"^)
   echo.path = "%file2%"
   echo.Set objFSO = CreateObject("Scripting.FileSystemObject"^)
   echo.Set objFile = objFSO.OpenTextFile(path, 2, true^)
   echo.objFile.WriteLine ClipboardText
   echo.objFile.Close )>>"%temp%\clipboard.vbs"
"%temp%\clipboard.vbs"
ping localhost -n 2 >nul
del /F /Q %temp%\clipboard.vbs

This will copy the content to clipboard then make a file and copy the content to it.
Don't forget to change the setting part in the batch file.

:by the way if the notepad can open it and you can read it just change .fpr to .txt
and check this too http://www.dostips.com/forum/viewtopic.php?f=3&t=3030

ladduq
Posts: 31
Joined: 22 Jan 2012 01:08

Re: Need to output the contents of a specific file

#6 Post by ladduq » 15 Mar 2012 04:36

@abc0502

Hi

Thank you for replying.

It is not working.

Regards
Ladduq

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Need to output the contents of a specific file

#7 Post by Ed Dyreen » 15 Mar 2012 21:35

'
Maybe I can help but only if
foxidrive wrote:We'd need to see a sample of the file, and also be told what format you want the output to look like.
Which OS you have, cause this code isn't universal.
abc0502 wrote:

Code: Select all

clip < "%file1%"

On top of that, it's simply wrong.

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Need to output the contents of a specific file

#8 Post by abc0502 » 15 Mar 2012 23:03

Ed Dyreen wrote:'
Maybe I can help but only if
foxidrive wrote:We'd need to see a sample of the file, and also be told what format you want the output to look like.
Which OS you have, cause this code isn't universal.
abc0502 wrote:

Code: Select all

clip < "%file1%"

On top of that, it's simply wrong.

he came her for a batch file so the os must be windows and the out put is text
see the end of the code
sourceanalyzer -scan -b buildid -f reports.txt

and i have a question why

Code: Select all

clip < "%file1%"

is wrong i tested the batch on text file and exe file it will out put the content if it is just readable text so if his content isn't readable like exe files he will need the program that generate the fpr file to read it

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Need to output the contents of a specific file

#9 Post by Ed Dyreen » 15 Mar 2012 23:35

'
My bad, I meant which version of windows you use :roll:
The clip command

Code: Select all

Microsoft Windows XP [versie 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\PROFSYS\ADMIN>clip
clip wordt niet herkend als een interne
of externe opdracht, programma of batchbestand.

C:\PROFSYS\ADMIN>echo.%errorlevel%
9009
I guess you meant

Code: Select all

>"%temp%\clipboard.vbs" (
   echo.Set objHTML = CreateObject("htmlfile"^)
   echo.ClipboardText = objHTML.ParentWindow.ClipboardData.GetData("text"^)
   echo.path = "%file2%"
   echo.Set objFSO = CreateObject("Scripting.FileSystemObject"^)
   echo.Set objFile = objFSO.OpenTextFile(path, 2, true^)
   echo.objFile.WriteLine ClipboardText
   echo.objFile.Close
)
"%temp%\clipboard.vbs"
without the additional

Code: Select all

>>"%temp%\clipboard.vbs"
But it may still work, not on my XP though, that's why I ask which OS he use.
But maybe I'm just old-school :wink:

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Need to output the contents of a specific file

#10 Post by foxidrive » 16 Mar 2012 00:48

Ed Dyreen wrote:d

Code: Select all

Microsoft Windows XP [versie 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\PROFSYS\ADMIN>clip
clip wordt niet herkend als een interne
of externe opdracht, programma of batchbestand.


He's using that new fandangled Windows, maybe.

Code: Select all

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\dos>clip /?

CLIP

Description:
    Redirects output of command line tools to the Windows clipboard.
    This text output can then be pasted into other programs.

Parameter List:
    /?                  Displays this help message.

Examples:
    DIR | CLIP          Places a copy of the current directory
                        listing into the Windows clipboard.

    CLIP < README.TXT   Places a copy of the text from readme.txt
                        on to the Windows clipboard.



Why didn't MS make the tool able to read the clipboard as well?? Maybe that will be the enhancement in Windows 9.

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Need to output the contents of a specific file

#11 Post by abc0502 » 16 Mar 2012 09:34

Hi, Ed Dyreen I use windows 7 , i didn't use clip before and the first time was on 7 so i thought it was on xp too
and now i understand why u said "this code isn't universal" :)

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Need to output the contents of a specific file

#12 Post by abc0502 » 16 Mar 2012 10:07

hi ladduq u said that the command:

Code: Select all

sourceanalyzer -scan -b buildid -f reports.txt 

doesn't work for the big file, see page 59 & 60 in the guide it talking about "Java  Heap  Exhaustion" i don't know what is it exactly but the problem is about heap space the default is 600 mb so basicly u will need to give more space then out put the reports.txt and then post the file so we can help in getting the lines u need.

ladduq
Posts: 31
Joined: 22 Jan 2012 01:08

Re: Need to output the contents of a specific file

#13 Post by ladduq » 17 Mar 2012 02:39

Hi

I use windows xp operating system

Regards
Ladduq
Last edited by ladduq on 16 May 2012 04:12, edited 1 time in total.

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Need to output the contents of a specific file

#14 Post by abc0502 » 18 Mar 2012 08:07

Hi .. again
the symbols are in the results.fpr ... right!

you can select the output formate using "-format <format>" option
the allowed formats is fpr,fvd1,text and auto
so the output can be a text format and you can't read it if you did't put the option "format"
the "auto" is set as default and the output will be fpr type even if you write "-f results.txt"
i guess the code must be:

Code: Select all

sourceanalyzer -scan -b buildid -format text -f reports.txt

or

Code: Select all

sourceanalyzer -scan -b buildid -format txt -f reports.txt 

(i'm not sure txt or text)
in guide page no#35 "output options"
then if you want to search for a text in that file it will be easy using batch but if still symbols i guess there is no chance.
good luck :)

ladduq
Posts: 31
Joined: 22 Jan 2012 01:08

Re: Need to output the contents of a specific file

#15 Post by ladduq » 19 Mar 2012 01:30

@abc0502

Hi

Thank You all for all the help

:)

Post Reply