Friday 5 October 2012

Convert MomentoApp to HTML Using Powershell

Lately I've been using the iPhone app Momento as a photo food diary which has been working well:


The problem with the Momento app is that the file export is just a flat text file with the image file names which is kind of depressing:



The lack lacklustre export functionality has been discussed in this thread on the Momento website and there doesn't seem any plans to improve it.


I've started writing a powershell script to parse the Momento text file, the script uses regular expression and creates a powershell object which can then be used to export the data into different formats.


Clear-Host
 
$strContent = Get-Content "D:\Temp\momento\momento\Momento Export 2012.10.01 at 12.52.55\2012.10.01 - Momento Export.txt"
 
$List = @()
 
ForEach($line in $strContent)
{
      IF ($line -match "((Mon)|(Tues)|(Wednes)|(Thurs)|(Fri)|(Satur)|(Sun))day (\d|\d\d) .* \d\d\d\d")
      {
            $txtEntryDate = $line
      }
     
      IF ($line -match "(\d|\d\d):\d\d (AM|PM)")
      {
            $Entry = new-object PSObject | select-object EntryDate, EntryTime, EntryDesc,EntryImage
            $Entry.EntryDate = $txtEntryDate
            $Entry.EntryTime = $line.Substring(0,8).Trim() 
            $Entry.EntryDesc = $line.Substring(8).Trim()
      }
     
      IF ($line -match "Photos:")
      {
            $Image = $line.Replace("Photos: ","")
            $Entry.EntryImage = ""
      }
     
      IF ($line -match "---")
      {
            #$Entry
            $List += $Entry
            $Entry = $null
      }
      #return $Entry
     
}
 
$a = ""
 
$List | ConvertTo-HTML -Head $a |foreach {$_.replace("<","<").replace(">",">").replace(""","`"")}


Just edit this line in the script to point to your unzipped Momento text file :

$strContent = Get-Content "D:\Temp\Momento Export 2012.10.01 at 12.52.55\2012.10.01 - Momento Export.txt"

and then run the script which will give you some outputted html.