Pages: [1] :: one page |
|
Author |
Thread Statistics | Show CCP posts - 0 post(s) |
Battlecheese
Caldari Black Knight Buccaneers Strength in Numbers.
|
Posted - 2008.11.16 23:31:00 -
[1]
EVE has lovely logging. Unfortunately it keeps them all in 1 directory which rapidly becomes unmanageable after a few weeks.
What's needed: a trivial app to move log files out of their directory, and archive them by month. (so that text search tools don't gag etc).
So, here is my humble offering. If a GUI is necessary, someone who cares a bit more then me can do it...
using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Text;
namespace EVEO_Archiver { class Program { static String archive_root = @"C:\Misc\Archive";
static void Main(string[] args) { Console.Write("Working with archive root: " + archive_root + "\nIs this ok? [yn]"); String yesno = Console.ReadLine(); if (!yesno.Equals("y")) { Console.WriteLine("Sorry, we only handle the default root for now..."); return; }
// we must be ok. Check our path. String cwd = Directory.GetCurrentDirectory(); // cwd = @"C:\Misc\CCP_DATA\test"; DirectoryInfo pwd = new DirectoryInfo(cwd); DirectoryInfo root = new DirectoryInfo(archive_root);
Console.Write("Character name: " + pwd.Name + "\nis this correct? [yn]"); yesno = Console.ReadLine(); if (!yesno.Equals("y")) { Console.WriteLine("... Find your silly profile directory then... noob."); return; }
// archive directory DirectoryInfo arch = new DirectoryInfo(root.FullName + @"\" + pwd.Name); // initialise the archive location. if (!arch.Exists) { Console.WriteLine("No existing records for this character - creating."); arch.Create(); }
// locate the logs. DirectoryInfo logs = new DirectoryInfo(pwd.FullName + @"\My Documents\EVE\logs");
Console.WriteLine("We will be moving stuff from " + logs + " to " + arch); if (!logs.Exists) { // bad. Logs must exist. Console.WriteLine("Logs not found at: " + logs.FullName); return; }
// check we know what to do with the stuff in pwd. DirectoryInfo[] test = logs.GetDirectories(); int i; for (i = 0; i < test.Length; i++) { if (test[i].Name.Equals("Chatlogs") || test[i].Name.Equals("Gamelogs")) { // process the chatlogs. Console.WriteLine("Processing: " + test[i].Name); process(arch.CreateSubdirectory(test[i].Name), test[i].GetFiles()); // Console.ReadLine(); } else { Console.WriteLine("Ignoring: " + test[i].Name); } } }
static void process(DirectoryInfo archiveDir, FileInfo[] raw_logs) { int length = raw_logs.Count(); int i; if (!archiveDir.Exists) archiveDir.Create(); Console.Write("Moving " + length + " files:"); char[] splitters = { '_', '.'}; for (i = 0; i < length; i++) { if (i % 50 == 0) Console.Write("."); String[] str = raw_logs[i].Name.Split(splitters); String date = str[str.Length - 3].Substring(0,6); // Console.WriteLine(raw_logs[i].Name + " -> " + date); raw_logs[i].MoveTo(archiveDir.CreateSubdirectory(date).FullName + @"\" + raw_logs[i].Name); } Console.Write("Done.\n"); return; } }
}
|
Dragonaire
Caldari Corax.
|
Posted - 2008.11.17 01:02:00 -
[2]
My only comment for now is what language is it in? Just a guess on my part that it's maybe Perl but doesn't look confusing enough like I find most script for it -- Finds camping stations from the inside much easier. Been known to write some PHP code for API from time to time too. |
Battlecheese
Caldari Black Knight Buccaneers Strength in Numbers.
|
Posted - 2008.11.17 01:10:00 -
[3]
Originally by: Dragonaire My only comment for now is what language is it in? Just a guess on my part that it's maybe Perl but doesn't look confusing enough like I find most script for it
It's in C#. tbh a compiled language is overkill. awk or powershell would have been more than sufficient. |
Tonto Auri
Vhero' Multipurpose Corp
|
Posted - 2008.11.18 01:12:00 -
[4]
Nah! Easy sh script is all it need. (For those poor people without GNU tools, there are decent amount of Windows ports, including Cygwin) -- Thanks CCP for cu |
Battlecheese
Caldari Black Knight Buccaneers Strength in Numbers.
|
Posted - 2008.11.18 02:41:00 -
[5]
Originally by: Tonto Auri Nah! Easy sh script is all it need. (For those poor people without GNU tools, there are decent amount of Windows ports, including Cygwin)
Well, I'm not sure how useful it will be for most people, but sure...
#!/bin/sh root=repo logs='My Documents/EVE/logs' charname=`pwd | sed 's/.*\/\(.*\)$/\1/'` if [ ! -d $root/$charname ];then mkdir $root/$charname ; fi for i in `ls "$logs"` ; do if [ "$i" = "Gamelogs" -o "$i" = "Chatlogs" ] ; then if [ ! -d "$root/$charname/$i" ];then mkdir "$root/$charname/$i" ; fi for j in `ls "$logs/$i"`; do month=`echo "$j" | sed 's/.*_\(.\{6\}\).\{2\}_.\{10\}$/\1/'` if [ ! -d "$root/$charname/$i/$month" ];then mkdir "$root/$charname/$i/$month" ; fi mv "$logs/$i/$j" "$root/$charname/$i/$month/" done fi done
|
|
|
|
Pages: [1] :: one page |
First page | Previous page | Next page | Last page |