I want to do the following if the folder doesn't exist then create it, but if I execute my script (second time) obviously will be already so I need to remove the folder and download the file inside, but my current script overwrites the location, and demo
becomes a file, how can I do this?
import os, shutil, wget
base_path = os.path.dirname(os.path.abspath(__file__))
directory = os.path.join(base_path, 'demo')
# check for extraction directories existence
if not os.path.isdir(directory):
os.makedirs(directory)
else:
if os.path.exists(directory) and os.path.isdir(directory):
shutil.rmtree(directory)
#os.makedirs(directory)
remote_location = 'https://github.com/facebookresearch/SING/blob/master/sing/nsynth/examples.json.gz?raw=true'
try:
wget.download(remote_location, out=directory)
except:
pass