-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdel-from-log.py
26 lines (20 loc) · 921 Bytes
/
del-from-log.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
# Script to delete corrupt media files from log generated by:
# https://gist.github.com/Desani/129be27da7d735d7c75192ec1aa96c65#file-scanmedia-ps1
# run ScanMedia.ps1 in same directory as ffmpeg.exe, path to scan as arg
import os #Enable filesystem functionality
import shutil #Enable file manipulation
from pathlib import Path
allfiles=[line.strip() for line in open('results2.log')] #Import file list and remove newlines
movedfiles = []
delpath = r'K:\\media\\Media Server No Dupe\\Deleted Media Trashcan\\Movies'
for folderName, subfolders, filenames in os.walk(delpath):
for filename in filenames:
movedfiles = [filename]
for file in range(len(allfiles)):
testfile = allfiles[file-1]
if 'ERROR: Error found: K:' in testfile:
before, sep, after = testfile.partition('ERROR: Error found: ')
try:
shutil.move(os.path.abspath(after), delpath)
except:
pass