Skip to content

Instantly share code, notes, and snippets.

@yjzhang
Last active November 12, 2019 09:44
Show Gist options
  • Save yjzhang/09c878afbb9446e7cd99134a0237bc9c to your computer and use it in GitHub Desktop.
Save yjzhang/09c878afbb9446e7cd99134a0237bc9c to your computer and use it in GitHub Desktop.
import os
import subprocess
filenames = os.listdir('.')
for filename in filenames:
name = filename.split('_')[0]
if not os.path.exists(name):
os.makedirs(name)
os.rename(filename, os.path.join(name, filename))
if filename.endswith('zip'):
subprocess.call(['unzip', os.path.join(name, filename), '-d', name])
for base, dirs, files in os.walk('.'):
for filename in files:
if filename.endswith('ipynb'):
subprocess.call(['jupyter', 'nbconvert', os.path.join(base, filename), '--to', 'pdf'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment