for file in *.pdf; do evince-thumbnailer -s 400 $file $file.png; done
for file in *.mp4; do totem-video-thumbnailer -rs 400 $file $file.png; done
| # This adds the "preview" column to the CSV | |
| # Plus do some cleaning I've needed last time. | |
| import csv | |
| with open('/path/to/source.csv') as source: | |
| with open('/path/to/destination.csv', 'w') as dest: | |
| rows = csv.DictReader(source) | |
| dest = csv.DictWriter(dest, fieldnames=rows.fieldnames + ['preview']) | |
| dest.writeheader() | |
| for row in rows: | |
| path = row['path'] | |
| path = path.split('\\')[-1] | |
| path = path.replace(' ', '_') | |
| path = path.replace('(', '') | |
| path = path.replace(')', '') | |
| path = path.replace(',', '') | |
| path = path.replace('&', '') | |
| path = path.replace('?', '') | |
| path = path.replace('؟', '') | |
| path = path.replace('’', '') | |
| path = path.replace('#', '') | |
| path = path.replace('–', '') | |
| path = path.replace('ّ', '') | |
| row['path'] = path | |
| if row['kind'] == 'mp4': | |
| row['kind'] = 'video' | |
| if row['kind'] in ('pdf', 'video'): | |
| row['preview'] = path + '.png' | |
| dest.writerow(dict(row)) |