-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrename.py
More file actions
41 lines (27 loc) · 1.13 KB
/
Copy pathrename.py
File metadata and controls
41 lines (27 loc) · 1.13 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
import subprocess
change_resolution_command = "convert ./dataset/train/*.jpg -resize 200x200! ./dataset/train/new"
rename_files_command = "for FN in ./dataset/train/*; do mv $FN ./$FN.jpg ; done"
remove_files_command = "rm -rf ./dataset/train/*.jpg"
move_files_command = "mv ./dataset/train/*.jpg ./dataset/train/old/"
rename_old_command = "mv ./dataset/train/old.* ./dataset/train/old"
path = "./dataset/train/"
print_files_command = "ls " + path
# subprocess.call("echo Changing Directory: ", shell=True)
# subprocess.call(change_dir_commmand, shell=True)
try:
print("Existing Structure")
subprocess.call(print_files_command, shell=True)
print("Changing resolution to 200x200")
subprocess.call(change_resolution_command, shell=True)
print("Deleting old files")
subprocess.call(move_files_command, shell=True)
print("Renaming Files")
subprocess.call(rename_files_command, shell=True)
print("New Structure")
subprocess.call(print_files_command, shell=True)
print("Renaming Old")
subprocess.call(rename_old_command, shell=True)
except:
print("ERROR ==> Create foldes old and new in the target folder")
finally:
print("DONE")