Skip to content

Instantly share code, notes, and snippets.

@Mahdisadjadi
Created March 7, 2016 22:11
Show Gist options
  • Save Mahdisadjadi/908f87e10735295aafe4 to your computer and use it in GitHub Desktop.
Save Mahdisadjadi/908f87e10735295aafe4 to your computer and use it in GitHub Desktop.
Delete files when list of names is in a file
# This removes files where paths are listed in a file named "file.dat".
# for running, type:
# python3 script.py file.dat
import sys
import os
paths = sys.argv[1]
with open(paths) as f:
for line in f:
os.remove(line.rstrip('\n'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment