Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thespacedoctor/c87917cf0f4c2a3969182ee3ec567545 to your computer and use it in GitHub Desktop.
Save thespacedoctor/c87917cf0f4c2a3969182ee3ec567545 to your computer and use it in GitHub Desktop.
[Generate Books of the Bible as Nested Folders] #bible
#!/usr/local/bin/python
# encoding: utf-8
"""
*Generate books of the bible and chapters as nested folders*
:Author:
David Young
:Date Created:
August 14, 2015
:Notes:
- If you have any questions requiring this script please email me: davidrobertyoung@gmail.com
"""
################# GLOBAL IMPORTS ####################
import sys
import os
def main(arguments=None):
bibleBooks = [
{"bookName": "Genesis", "chapters": 50},
{"bookName": "Exodus", "chapters": 40},
{"bookName": "Leviticus", "chapters": 27},
{"bookName": "Numbers", "chapters": 36},
{"bookName": "Deuteronomy", "chapters": 34},
{"bookName": "Joshua", "chapters": 24},
{"bookName": "Judges", "chapters": 21},
{"bookName": "Ruth", "chapters": 4},
{"bookName": "1 Samuel", "chapters": 31},
{"bookName": "2 Samuel", "chapters": 24},
{"bookName": "1 Kings", "chapters": 22},
{"bookName": "2 Kings", "chapters": 25},
{"bookName": "1 Chronicles", "chapters": 29},
{"bookName": "2 Chronicles", "chapters": 36},
{"bookName": "Ezra", "chapters": 10},
{"bookName": "Nehemiah", "chapters": 13},
{"bookName": "Esther", "chapters": 10},
{"bookName": "Job", "chapters": 42},
{"bookName": "Psalms", "chapters": 150},
{"bookName": "Proverbs", "chapters": 31},
{"bookName": "Ecclesiastes", "chapters": 12},
{"bookName": "Song of Songs", "chapters": 8},
{"bookName": "Isaiah", "chapters": 66},
{"bookName": "Jeremiah", "chapters": 52},
{"bookName": "Lamentations", "chapters": 5},
{"bookName": "Ezekiel", "chapters": 48},
{"bookName": "Daniel", "chapters": 12},
{"bookName": "Hosea", "chapters": 14},
{"bookName": "Joel", "chapters": 3},
{"bookName": "Amos", "chapters": 9},
{"bookName": "Obadiah", "chapters": 1},
{"bookName": "Jonah", "chapters": 4},
{"bookName": "Micah", "chapters": 7},
{"bookName": "Nahum", "chapters": 3},
{"bookName": "Habakkuk", "chapters": 3},
{"bookName": "Zephaniah", "chapters": 3},
{"bookName": "Haggai", "chapters": 2},
{"bookName": "Zechariah", "chapters": 14},
{"bookName": "Malachi", "chapters": 4},
{"bookName": "Matthew", "chapters": 28},
{"bookName": "Mark", "chapters": 16},
{"bookName": "Luke", "chapters": 24},
{"bookName": "John", "chapters": 21},
{"bookName": "Acts", "chapters": 28},
{"bookName": "Romans", "chapters": 16},
{"bookName": "1 Corinthians", "chapters": 16},
{"bookName": "2 Corinthians", "chapters": 13},
{"bookName": "Galatians", "chapters": 6},
{"bookName": "Ephesians", "chapters": 6},
{"bookName": "Philippians", "chapters": 4},
{"bookName": "Colossians", "chapters": 4},
{"bookName": "1 Thessalonians", "chapters": 5},
{"bookName": "2 Thessalonians", "chapters": 3},
{"bookName": "1 Timothy", "chapters": 6},
{"bookName": "2 Timothy", "chapters": 4},
{"bookName": "Titus", "chapters": 3},
{"bookName": "Philemon", "chapters": 1},
{"bookName": "Hebrews", "chapters": 13},
{"bookName": "James", "chapters": 5},
{"bookName": "1 Peter", "chapters": 5},
{"bookName": "2 Peter", "chapters": 3},
{"bookName": "1 John", "chapters": 5},
{"bookName": "2 John", "chapters": 1},
{"bookName": "3 John", "chapters": 1},
{"bookName": "Jude", "chapters": 1},
{"bookName": "Revelation", "chapters": 22}
]
# Recursively create missing directories
if not os.path.exists("/Users/Dave/Desktop/bible"):
os.makedirs("/Users/Dave/Desktop/bible")
for i, book in enumerate(bibleBooks):
count = i + 1
count = "b%(count)02d" % locals()
thisBook = book["bookName"]
bookPath = "/Users/Dave/Desktop/bible/%(count)s - %(thisBook)s" % locals(
)
bookPath2 = "/Users/Dave/Desktop/bible/%(count)s - %(thisBook)s/%(thisBook)s" % locals(
)
if not os.path.exists(bookPath):
os.makedirs(bookPath)
if not os.path.exists(bookPath2):
os.makedirs(bookPath2)
if book["chapters"] < 100:
for j in range(1, book["chapters"] + 1):
thisPath = "%(bookPath2)s/c%(j)02d" % locals()
if not os.path.exists(thisPath):
os.makedirs(thisPath)
else:
for j in range(1, book["chapters"] + 1):
thisPath = "%(bookPath2)s/c%(j)03d" % locals()
if not os.path.exists(thisPath):
os.makedirs(thisPath)
return
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment