import os, sys
def create_dir_from_file(filepath):
if not os.path.isfile(filepath):
return
path, ext = os.path.splitext(filepath)
root, file = os.path.split(filepath)
if ext == '':
return
if os.path.isfile(path):
return
os.makedirs(path, exist_ok=True)
newpath = os.path.join(path, file)
os.rename(filepath, newpath)
def main(args):
for arg in args:
create_dir_from_file(arg)
if __name__ == "__main__":
import sys
main(sys.argv[1:])