123456789101112131415161718 |
- def advance_touch(paths, cd):
- """ Make folders and files """
- for path in paths:
- # Make folders
- new_dirs = '/'.join(path.split('/')[0:-1])
- if not os.path.exists(new_dirs) and new_dirs != '':
- os.makedirs(new_dirs)
- # Change directory
- if cd:
- cd_path = os.path.join(os.getcwd(), new_dirs) + '/'
- os.chdir(cd_path)
- # Make file
- if not path.endswith('/') and not os.path.isfile(path):
- try:
- open(path, 'w+').close()
- except IsADirectoryError:
- pass
|