#!/usr/bin/python3

# Script designed to help me sort through the chat logs I recovered after
# I accidentally deleted all of them

# pipe the output of fdupes -q -r . into this
# pipe the output of this into /bin/sh

import sys

logs = './logs/'
lenlogs = len(logs)
logs1 = './logs1/'
lenlogs1 = len(logs1)
undelete = './undelete/'
lenundelete = len(undelete)

lines = sys.stdin.read()

for files in lines.split('\n\n'):
	files = files.split('\n')
	n = len(files)
	prefs = [0,]*n
	i = 0
	for f in files:
		if f[:lenlogs] == logs:
			prefs[i] = 4
			if f.count('(') > 0:
				prefs[i] = 3
		elif f[:lenlogs1] == logs1:
			prefs[i] = 2
			if f.count('(') > 0:
				prefs[i] = 1
		i += 1
	maxx = max(prefs)
	i = 0
	for pref in prefs:
		if pref == maxx:
			files[i] = '#     ' + files[i] + '   |-----------------'
		else:
			files[i] = 'rm -f \'' + files[i] + '\''
		i += 1
	print('\n'.join(files) + '\n')
