Putting all the 10X and 4X files together
import os
import shutil
import pandas
directory = 'Inflamed'
for filename in os.listdir(directory):
f = os.path.join(directory, filename)
# checking if it is a file
if len(f) >30:
new_folder = f[10:29]
new_dir = directory + "/../" + new_folder
isExist = os.path.exists(new_dir)
if not isExist:
os.makedirs(new_dir)
for cur_file in os.listdir(directory):
fut = os.path.join(directory, cur_file)
if os.path.isdir(fut):
continue
fut_name = fut[10:29]
if (fut_name == new_folder):
shutil.move(fut, new_dir)
import os
import shutil
import pandas
new_dir = 'Inflamed_10x'
directory = 'InflamedFinal'
isExist = os.path.exists(new_dir)
if not isExist:
os.makedirs(new_dir)
for filename in os.listdir(directory):
f = os.path.join(directory, filename)
if f.find("10X") < 0:
continue
shutil.move(f, new_dir)
import os
import shutil
import pandas
new_dir = 'Inflamed_20x'
directory = 'InflamedFinal'
isExist = os.path.exists(new_dir)
if not isExist:
os.makedirs(new_dir)
for filename in os.listdir(directory):
f = os.path.join(directory, filename)
if f.find("20X") < 0:
continue
shutil.move(f, new_dir)
import os
import shutil
import pandas
new_dir = 'Inflamed_4x'
directory = 'InflamedFinal'
isExist = os.path.exists(new_dir)
if not isExist:
os.makedirs(new_dir)
for filename in os.listdir(directory):
f = os.path.join(directory, filename)
if f.find("4X")<0:
continue
shutil.move(f, new_dir)
import os
import shutil
import pandas
new_dir = 'Inflamed_40x'
directory = 'InflamedFinal'
isExist = os.path.exists(new_dir)
if not isExist:
os.makedirs(new_dir)
for filename in os.listdir(directory):
f = os.path.join(directory, filename)
if f.find("40x") < 0:
continue
shutil.move(f, new_dir)