Skip to content

Instantly share code, notes, and snippets.

@arisada
Created March 24, 2022 21:36
Show Gist options
  • Save arisada/b954852eaf055ab495b895ef609c9317 to your computer and use it in GitHub Desktop.
Save arisada/b954852eaf055ab495b895ef609c9317 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import sys
import os
"""
Deletes all FIT files from a Siril sequence file (.seq)
"""
def parse_seq(seq):
for l in seq.readlines():
l=l.strip()
if len(l) == 0:
continue
if l[0] == "#":
continue
if l[0] == 'S':
tokens = l.split(' ')
if len(tokens) != 8:
continue
S, name, start_index, nb_images, nb_selected, fixed_len, reference_image, version = tokens
if S != 'S':
continue
if name[0] != '\'' or name[-1] != '\'':
continue
name = name[1:-1]
print("Sequence ", name, start_index, nb_images)
return name, int(start_index), int(nb_images)
def main(args):
if len(args) < 1:
print("Usage: rmseq.py seqfile.seq [...]")
return
for sequence in args:
with open(sequence) as seq:
name, start, nb = parse_seq(seq)
filenames = ["%s%.5d.fit"%(name, i) for i in range(start, start+nb)]
for f in filenames:
try:
os.stat(f)
except FileNotFoundError:
print("Warning: file %s does not exist"%(f,))
return
print("deleting", filenames)
for f in filenames:
os.unlink(f)
os.unlink(args[0])
if __name__== "__main__":
main(sys.argv[1:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment