Jump to content

Recommended Posts

Posted

Not related to my post yesterday about a website IM program,

 

 

Currently I'm using IPswitch IM system at one of my school districts for teacher to teacher chat hosted on a local server and i'm pulling at least 10,000 IM chat logs in every other month in .rtf format . I've been able to combine them all by changing them to .txt files using (RTFtoUTXT) a free program used for changing mass amounts of .rtf files to .txt files. Then I proceed to use a program called simple file joined (SFJ) that joins all my logs together. But SFJ seems to be bugged and designed by a young child who was banging on a keyboard. Sometimes it will insert dividers written in Chinese text, other times it will put a bunch of script and file locations. When it does work though it puts triple spaces between all the charecters in a text document like "h e l l o".

 

 

What I'm trying to get to Is does anyone know of a good program to combine .log, .rtf or .txt files

without any issues and simple dividers?

 

 

 

 

(To put things in perspective when finished i had about 2.4 millions words and 6,203 thousand pages on word with Calibri 10)

 

 

Thanks

Posted

.bat file would be hard. Wouldn't i have to type out each file name? like... (remember i dealing with 10,000+ files)

"name.txt name.txt name.txt >masterfile.txt"

 

And for txt collector I kept getting errors once i compiled them. I would list the title the "could not be written" after each one.

Posted

That's a shame - txt collector used to be really good.

 

That code I put in above should iterate through every .txt file in the folder and "type" the contents into the combined.txt file, so you wouldn't need to type out the filenames. (It will do every txt file in that folder though!)

 

I don't think it does line breaks though, so you will probably end up with a bit of:

 

File 1 starts here

File 1 contents

File 1 ends hereFile 2 starts here

File 2 contents

File 2 ends hereFile 3 starts here

 

so not 100% ideal :/

Posted
does anyone know of a good program to combine .log or .txt files without any issues and simple dividers?

PowerShell should do this easily. The two scripts below both do exactly the same thing - the only difference is the second one reads .txt files from every subdirectory within the source folder. Each file will be separated by a blank line in the concatenated text file.

 

$SourcePath = "C:\Source"
$Pattern = "*.txt"
$OutputFile = "C:\Destination\Combined.txt"

[system.IO.Directory]::GetFiles($SourcePath, $Pattern) | ForEach-Object { [system.IO.File]::ReadAllText($_) + [Environment]::NewLine } | Out-File -filepath $OutputFile -Append

 

$SourcePath = "C:\Source"
$Pattern = "*.txt"
$OutputFile = "C:\Destination\Combined.txt"

[system.IO.Directory]::GetFiles($SourcePath, $Pattern, [system.IO.SearchOption]::AllDirectories) | ForEach-Object { [system.IO.File]::ReadAllText($_) + [Environment]::NewLine } | Out-File -filepath $OutputFile -Append

 

Note. Do not save the output file to the source folder, otherwise PowerShell will go into an infinite loop and fill your hard drive up. :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...