correctly trim filenames, finish label writing