Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pathlib import Path
- from shutil import copyfile
- def copy_n_times(file_path: Path, n: int = 1) -> None:
- for i in range(1, n + 1):
- dst_file_path = Path(file_path.parent,
- file_path.stem + f'{i}' + file_path.suffix)
- copyfile(file_path, dst_file_path)
- if __name__ == '__main__':
- file_to_copy = Path(r'image.jpg')
- copy_n_times(file_to_copy, 5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement