-
Notifications
You must be signed in to change notification settings - Fork 12
/
extract_osrs_zip.py
32 lines (23 loc) · 997 Bytes
/
extract_osrs_zip.py
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
import os
import pathlib
import zipfile as z
# project path
directory = pathlib.Path(__file__).parent.resolve()
# dataset path
zipPath = '\\datasets\\'
# final path
dir_name = str(directory) + zipPath
# change directory to ensure files can be copied and unzipped
os.chdir(dir_name)
print(str(directory))
#first command is to change directory in command prompt (cmd.exe)
first_cmd = 'cd ' + str(directory) + '\datasets\\'
#final command is to copy the binary data of any file in the folder ending in cow.zip.xxx and save result as output.zip
final_cmd = 'copy /B cow.zip.* output.zip'
# run commands in command prompt and terminate once done (/c)
os.system('cmd /c ' + first_cmd + ' & dir & ' + final_cmd)
# unzip resulting file output.zip, this will have all the jpg and xml files
with z.ZipFile(str(directory) + "\datasets\output.zip", 'r') as zip_ref:
zip_ref.extractall(str(directory) + "\datasets\osrs\\")
import png_to_jpg
import convert_xml_data