-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIrChecker.py
More file actions
53 lines (39 loc) · 1.25 KB
/
IrChecker.py
File metadata and controls
53 lines (39 loc) · 1.25 KB
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
# -*- coding: utf-8 -*-
"""
Created on Fri May 20 15:59:52 2022
@author: rossc
"""
import os, sys, datetime, glob, time, shutil
def readin(fname):
f = open(fname)
lines = f.read()
f.close()
return lines
def IrChecker(folder, fname):
print(f"{folder}\{fname}")
single_folder = os.path.join(folder, "single")
multiple_folder = os.path.join(folder, "multiple")
lines = readin(f"{folder}/{fname}").split("\n")
count = 0
for line in lines:
if line.startswith("Ir"):
count += 1
else:
continue
if count == 1:
subsubfolder = single_folder
else:
subsubfolder = multiple_folder
if os.path.exists(f"{folder}\{fname}"):
shutil.move(f"{folder}\{fname}", f"{subsubfolder}\{fname}")
print(f"No of Ir = {count}. {fname} moved to {subsubfolder}")
if __name__ == "__main__":
tasks = glob.glob("CSD\\*.xyz")
folder = os.path.join(os.path.abspath("."), "CSD")
for subfolder in ["single", "multiple"]:
if not os.path.exists(f"CSD\{subfolder}"):
os.mkdir(f"CSD\{subfolder}")
else:
continue
for job in tasks:
IrChecker(folder, os.path.basename(job))