Skip to content

Instantly share code, notes, and snippets.

@amazedkoumei
Created May 20, 2012 17:48
Show Gist options
  • Save amazedkoumei/2758904 to your computer and use it in GitHub Desktop.
Save amazedkoumei/2758904 to your computer and use it in GitHub Desktop.
Bookscan FileName Converter
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os, re
path = os.getcwd() + "/"
p = re.compile('ipad3_(.+?)(\d+?p)_\d+?X?.pdf', re.IGNORECASE)
errBuff = []
for name in os.listdir("./"):
if p.match(name):
m = p.match(name)
title = m.group(1).strip()
page_count = m.group(2).strip()
print title + " " + page_count + " ipad3.pdf"
os.rename(path + name, path + title + " " + page_count + " ipad3.pdf")
elif name.startswith("ipad3"):
errBuff.append(name)
if len(errBuff) >0:
print "NG!!!!!!"
for name in errBuff:print name
"""
USAGE:
1. download this script to [SCRIPT_DIR]
2. download book files from Bookscan to [BOOK_DIR]
3. cd [BOOK_DIR]
4. python [SCRIPT_DIR]/ipad.py
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment