Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@1kastner
Created December 27, 2015 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1kastner/46a6e8510c47901cb55d to your computer and use it in GitHub Desktop.
Save 1kastner/46a6e8510c47901cb55d to your computer and use it in GitHub Desktop.
In case you needed to abort the downloads because of an unstable connection
import os
import os.path
import re
import shutil
DB_BASE = "/home/marvin/projectrepository/AudioFiles/voxforge"
for f in os.listdir("."):
match = re.match("(.*)\.tgz.[0-9]", f)
if match:
#print "examine: " + f
os.system("tar -zxvf %s" % f)
foldername = match.group(1)
for f2 in os.listdir(os.path.join(".", foldername, "wav")):
file_here = os.path.join(".", foldername, "wav", f2)
file_there = os.path.join(DB_BASE, foldername, "wav", f2)
if os.path.exists(file_there) and os.path.getsize(file_here) > os.path.getsize(file_there):
print "copy from " + file_here + " to " + file_there
print "(replacing broken file)"
shutil.copy2(file_here, file_there)
if not os.path.exists(file_there):
print "copy from " + file_here + " to " + file_there
print "(adding lost file)"
shutil.copy2(file_here, file_there)
print ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment