diff --git a/misc/move_files/move_files.py b/misc/move_files/move_files.py index 44cc3f4f7e61027b833a7774705577c59e756e72..7498feef96e3a6e2aee465518b34ebd64e4561e4 100755 --- a/misc/move_files/move_files.py +++ b/misc/move_files/move_files.py @@ -63,14 +63,20 @@ def rename(changes, chunksize=10): cont = db.Container() for _, (old, new) in chunk.iterrows(): - cont.append(db.File(path=old)) - - cont.retrieve() - - for fi, (_, (old, new)) in zip(cont, chunk.iterrows()): - assert fi.path == old - fi.path = new - cont.update() + try: + fi = db.File(path=old) + fi.retrieve() + + if not fi.is_valid(): + continue + assert fi.path == old + fi.path = new + cont.append(fi) + except Exception as e: + print(e) + + if len(cont) > 0: + cont.update(unique=False) i += 1