Saved Bookmarks
| 1. |
Solve : Covert Verticle Text to Horizontal Text? |
|
Answer» I am working on a batch file that scan server folder sizes and then creates data files for each folder that was scaned. Unfortunately I've GOTTEN hung up on how to convert data listed vertically to a text file with horizontal data. DataFile.Txt (Existing file Content) ABCD 1234 A2C4 1B3D ConvertedDataFile.Txt (New file content with space delimiter) ABCD 1234 A2C4 1B3D As an Overview: Attached is the .Bat the starts with a DU (System Internals) command. The commands port folder information information into a text file. The files are then washed until I have nothing but the 4 lines of vertical data per file. The main remaining task is to get the data horizontal, port horizontal data to a single file, and then import into a database. [attachment deleted by admin]Do you have Microsoft Office?You got this all wrong. You just lay the monitor on its side.! sibleytr - Welcome to the CH forums. Try the following code to convert your crlf delimited text to space delimited text. No line-wrap not even a crlf at END of file. The final character in the output file is a space. Code: [Select]@echo off cls for /f "tokens=*" %%a in (input_path\filename.ext) do ( <NUL (set/p z=%%a) >> output_path\filename.ext ) Good luck & please post back with your results. Here is my alternative: @echo off setlocal enabledelayedexpansion set output= for /f "delims==" %%L in (DataFile.Txt) do set output=!output! %%L echo %output%>ConvertedDataFile.Txt Code: [Select]'vert2horz.vbs Dim Inputfile,Outputfile dim spaced if wscript.arguments.count < 2 then showhelp else inputfile = wscript.arguments(0) outputfile = wscript.arguments(1) wscript.echo "Input file:" & inputfile wscript.echo "output file:" & outputfile 'get Filesystemobject.. set FSO = CreateObject("Scripting.FileSystemObject") 'retrieve file object, and open it as an input stream. set ReadIt = FSO.GetFile(inputfile).OpenAsTextStream(1) 'read text from input stream... Alltext = Readit.ReadAll() 'no explanation necessary. Readit.close() 'create the output file... set outstream = FSO.CreateTextFile(outputfile,TRUE) 'process the input string. replace crlf with spaces. spaced = replace(alltext,chr(13) & chr(10)," ") 'write to the output. outstream.write spaced outstream.close 'all done! end if Sub ShowHelp() Wscript.echo "Vert2Horz VBScript program." Wscript.echo "Usage: [CScript] Vert2Horz <inputfile> <outputfile>" Wscript.echo "Warning: if the output file already exists, it will be overwritten!" end sub hmm, it's a bit longer then the batch file solution... and who needs error handling, anyway?Thank you Dusty and Dias - Both will do what I need... BC great example, maybe some day I will upgrade to wscript |
|