Page MenuHomec4science

folder_structure.py
No OneTemporary

File Metadata

Created
Mon, Oct 14, 00:11

folder_structure.py

#!/usr/bin/env python
import sys
import os
if __name__=='__main__':
helpmess="""Usage:
folder_structure species.txt
Creates a subfolder for each species and the corresponding reference within.
"""
# Inputs
if len(sys.argv)<2:
print(helpmess)
sys.exit(0)
else:
infile=os.path.realpath(sys.argv[1])
with open(infile, 'r') as f:
for line in f:
# separate the elements
words = line.strip().split()
species = ('./' + '_'.join(words[0:2]))
ref = (species + '/' + '_'.join(words[2:]) + '.txt')
if not os.path.exists(species):
os.mkdir(species)
os.chown(species, 1000, 1000)
with open(ref, 'w') as o:
o.write('original description')

Event Timeline