Ubuntu: Making Directories from a List!

with No Comments

Today I decided to sort a bunch of Bible related files based upon what book of the Bible it was base on.  I decided to make one folder for each book of the Bible.  Gosh Batman, that means I needed to create 66 folders…  The thought of doing this by hand bothered me a lot. I decided to find a better way.

The List

I had already grabbed a list of the books, and came up with a self sorting format I could live with.  The first digit would be a”1″ for the Old Testament and a “2” for The New Testament.  After that I would add a two digit number for the number of the book, 01-30 for the Old Testament books and 01-27 for the New Testament books.  Then a “-” (dash) and finally the name of the book.

LibreOffice Calc had already produced this list for me.  I copy pasted it to my favorite Geany, and I saved it in a file I called “booklist”.  That file was in the folder I already had prepared for the head of all the Bible Book Folders.  I will just call it bible.

The booklist file looked like this…

101-Genesis
102-Exodus
103-Leviticus
104-Numbers
105-Deuteronomy
106-Joshua
107-Judges
108-Ruth
109-1Samuel
110-2Samuel
111-1Kings
112-2Kings
113-1Chronicles
114-2Chronicles
115-Ezra
116-Nehemiah
117-Esther
118-Job
119-Psalms
120-Proverbs
121-Ecclesiastes
122-Song-of-Songs
123-Isaiah
124-Jeremiah
125-Lamentations
126-Ezekiel
127-Daniel
128-Hosea
129-Joel
130-Amos
131-Obadiah
132-Jonah
133-Micah
134-Nahum
135-Habakkuk
136-Zephaniah
137-Haggai
138-Zechariah
139-Malachi
201-Matthew
202-Mark
203-Luke
204-John
205-Acts
206-Romans
207-1Corinthians
208-2Corinthians
209-Galatians
210-Ephesians
211-Philippians
212-Colossians
213-1Thessalonians
214-2Thessalonians
215-1Timothy
216-2Timothy
217-Titus
218-Philemon
219-Hebrews
220-James
221-1Peter
222-2Peter
223-1John
224-2John
225-3John
226-Jude
227-Revelation

To be sure not very complex of a file, but still just thinking of copy ad paste these 66 names into 66 new folders was more than I wanted to think about.

The Terminal

I now opened the Ubuntu Terminal and did a “cd” or two to the folder that had the “booklist” file in it. A quick “ls” (to be sure) and at the command prompt I typed in…

while read L; do mkdir "$L"; done < booklist

That’s it, I had 66 perfectly named folders, ready for me to fill up!

Ideas

You could use this list to folders trick for a lot of things. For example:

A list of new students, to hold their records.

A list of church members, to track attendance or donations for tax purposes.

A list of projects (like electronic building projects or computer code projects).

I am sure you would have many more ideas (feel free to list them below if you like!).

One Catch

Remember that your list is for making directories, so each line must be what can be the name of a directory.  In other words, no invalid characters!

Leave a Reply