Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- from icecream.icecream import ic
- # Get the absolute path of the current source file
- source_file_path = os.path.abspath(__file__)
- lst = source_file_path.split("\\")
- n = len(lst)
- ic(n)
- # folders = [f for f in os.listdir(path) if os.path.isdir(os.path.join(path, f))]
- # D:\python3\py\str.py
- filename = lst.pop()
- lst.pop()
- ic(lst)
- path1 = ""
- for p in lst:
- path1 = path1 + p + "\\"
- ic(path1)
- foldersNfiles = os.listdir(path1)
- folders = []
- for f in foldersNfiles:
- if os.path.isdir(os.path.join(path1, f)):
- folders.append(os.path.join(path1, f))
- ic(folders)
- for ff in folders:
- file_path = os.path.join(ff, filename)
- if file_path != source_file_path:
- command = "copy " + source_file_path + " " + file_path
- ic(command)
- os.system(command)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement