<commit_before>#!/usr/bin/python

#
# Quick script for naming the mp4 files produced by the Voice Memos app on iOS (tested on iOS 8.1.2).
#
#
#

import sqlite3
import os
import ntpath

print

conn = sqlite3.connect('Recordings.db')
c = conn.cursor()
c.execute("select ZPATH, ZCUSTOMLABEL from ZRECORDING")

res = c.fetchall()

fileNotFoundCount = 0
fileRenamedCount = 0

for (filePath, fileComment) in res:
	filename = ntpath.basename(filePath)
	newFilename = "%s %s.mp4" % (filename[:-4], fileComment)
	print "Renaming %s -> %s" % (filename, newFilename)

	if (os.path.exists(filename)):
		fileRenamedCount += 1
		os.rename(filename, newFilename)
	else:
		fileNotFoundCount += 1
		print "  -- couldn't find input file. Maybe it has already been processed?"

conn.close()

print
print "Finished processing %d files:" % len(res)
print "%d files were successfully renamed." % fileRenamedCount
if (fileNotFoundCount > 0):
	print "%d files could not be found for renaming." % fileNotFoundCount
print

<commit_msg>Comment change<commit_after>#!/usr/bin/python

#
# Quick script for naming the mp4 files produced by the Voice Memos app on iOS (tested on iOS 8.1.2).
#
# <NAME> 2015-01
#

import sqlite3
import os
import ntpath

print

conn = sqlite3.connect('Recordings.db')
c = conn.cursor()
c.execute("select ZPATH, ZCUSTOMLABEL from ZRECORDING")

res = c.fetchall()

fileNotFoundCount = 0
fileRenamedCount = 0

for (filePath, fileComment) in res:
	filename = ntpath.basename(filePath)
	newFilename = "%s %s.mp4" % (filename[:-4], fileComment)
	print "Renaming %s -> %s" % (filename, newFilename)

	if (os.path.exists(filename)):
		fileRenamedCount += 1
		os.rename(filename, newFilename)
	else:
		fileNotFoundCount += 1
		print "  -- couldn't find input file. Maybe it has already been processed?"

conn.close()

print
print "Finished processing %d files:" % len(res)
print "%d files were successfully renamed." % fileRenamedCount
if (fileNotFoundCount > 0):
	print "%d files could not be found for renaming." % fileNotFoundCount
print


{'fraction_non_alphanumeric': 0.11946902654867257, 'fraction_numerical': 0.015732546705998034, 'mean_word_length': 4.514905149051491, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4087169', 'n_tokens_mistral': 723, 'n_tokens_neox': 670, 'n_words': 221}