-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmove_results.py
More file actions
executable file
·95 lines (80 loc) · 3.03 KB
/
move_results.py
File metadata and controls
executable file
·95 lines (80 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env python
import argparse
from pathlib import Path
from shutil import copy2
def move_results(basename: str, verbose: bool) -> None:
# Source directory
base_directory = Path(__file__).parent / 'scripts'
# Target directories
movies_1920_dir = Path('/Volumes/Jedi/TimeLapse/Movies/1920/')
movies_960_dir = Path('/Volumes/Jedi/TimeLapse/Movies/960/')
movies_screensaver_dir = Path('/Users/Shared/Time-Lapse/Selected/')
thumbnail_output_dir = Path('/Volumes/Jedi/TimeLapse/Thumbs/Output/')
thumbnail_sources_dir = Path('/Volumes/Jedi/TimeLapse/Thumbs/Sources/')
thumbnail_website_dir = Path('~/Code/153957/153957/theme/static/images_timelapse/thumbs/').expanduser()
# Ensure all target directories are available
for directory in [
movies_1920_dir,
movies_960_dir,
movies_screensaver_dir,
thumbnail_output_dir,
thumbnail_sources_dir,
thumbnail_website_dir,
]:
if not directory.is_dir():
raise FileNotFoundError(f'Target directory "{directory}" does not exist.')
# Source files
thumbnail_file = base_directory / f'{basename}@2x.png'
thumbnail_source = base_directory / f'{basename}.tif'
video_1920 = base_directory / f'{basename}.mp4'
video_960 = base_directory / f'{basename}_960.mp4'
# Ensure all expected source files are available
for file in [
thumbnail_file,
thumbnail_source,
video_1920,
video_960,
]:
if not file.is_file():
raise FileNotFoundError(f'Source file "{file}" does not exist.')
# Copy files to target directories
copy2(thumbnail_file, thumbnail_output_dir / thumbnail_file.name)
copy2(thumbnail_file, thumbnail_website_dir / thumbnail_file.name)
copy2(thumbnail_source, thumbnail_sources_dir / thumbnail_source.name)
copy2(video_1920, movies_1920_dir / video_1920.name)
copy2(video_1920, movies_screensaver_dir / video_1920.name)
copy2(video_960, movies_960_dir / video_1920.name)
if verbose:
print('Moved files to the following locations:')
for path in (
thumbnail_output_dir / thumbnail_file.name,
thumbnail_website_dir / thumbnail_file.name,
thumbnail_sources_dir / thumbnail_source.name,
movies_1920_dir / video_1920.name,
movies_screensaver_dir / video_1920.name,
movies_960_dir / video_1920.name,
):
print(f' - {path}')
# Remove source files
for file in [
thumbnail_file,
thumbnail_source,
video_1920,
video_960,
]:
file.unlink()
def main() -> None:
parser = argparse.ArgumentParser(description='Move created output to final locations.')
parser.add_argument(
'basename',
help='Basename of the output.',
)
parser.add_argument(
'--verbose',
help='Show where the files were moved to.',
action='store_true',
)
kwargs = vars(parser.parse_args())
move_results(**kwargs)
if __name__ == '__main__':
main()