-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlab_make_directories_1.1.1.py
65 lines (48 loc) · 1.98 KB
/
lab_make_directories_1.1.1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python3
"""
Create a directory structure for new or existing collections.
Create a new directory structure based on the following structure:
collection_folder
item_folder
content
archive
display
raw
The collection_folder should have the following structure:
zttu_pressr
The first letter places the folder at the bottom of the directory and is
stripped when creating item folders. The next three letters are an institution
code (e.g. ttu for Texas Tech University). The last six letters are a unique
collection code.
The item_folder should have the following structure:
ttu_pressr_000001
The six digit number is a unique item number for each item in the collections.
If the collection directory exists, add additional subdirectories.
"""
import os
base_dir = input('Enter location to save directory (e.g. C:\\Users\\christopher\\Desktop): ')
collection_code = input('Enter collection code (e.g. zttu_pressr): ')
item_number = input('Enter first item number (e.g. 1): ')
number_of_items = int(input('Enter number of item folders needed (e.g. 100): '))
collection_folder = os.path.join(base_dir, collection_code)
collection_code_slice = collection_code[1:]
item_number = str(item_number).zfill(6)
if os.path.isdir(collection_folder):
pass
else:
os.mkdir(collection_folder)
for number in range(number_of_items):
item_folder = os.path.join(collection_folder,
(collection_code_slice + '_' + item_number))
content_folder = os.path.join(item_folder, 'content')
archive_folder = os.path.join(content_folder, 'archive')
display_folder = os.path.join(content_folder, 'display')
raw_folder = os.path.join(content_folder, 'raw')
os.mkdir(item_folder)
os.mkdir(content_folder)
os.mkdir(archive_folder)
os.mkdir(display_folder)
os.mkdir(raw_folder)
item_number = int(item_number)
item_number += 1
item_number = str(item_number).zfill(6)