diff --git a/misc/move_files/move_files.py b/misc/move_files/move_files.py
index 10c9bd00163a14956af894af21dff2eb7617344c..65d16125a07d08c1d13af26c9842922e99aff253 100755
--- a/misc/move_files/move_files.py
+++ b/misc/move_files/move_files.py
@@ -62,8 +62,6 @@ def rename(changes, chunksize=10):
             continue
         cont = db.Container()
 
-        cmap = {}
-
         for ii, (old, new) in chunk.iterrows():
             try:
                 fi = db.File(path=old)
@@ -71,17 +69,12 @@ def rename(changes, chunksize=10):
 
                 if not fi.is_valid():
                     continue
+                assert fi.path == old
+                fi.path = new
                 cont.append(fi)
-                cmap[ii] = len(cont)-1
             except Exception as e:
                 print(e)
 
-        for ii, (old, new) in chunk.iterrows():
-            if ii not in cmap:
-                continue
-            assert cont[cmap[ii]].path == old
-            cont[cmap[ii]].path = new
-
         if len(cont) > 0:
             cont.update(unique=False)
         i += 1