diff --git a/product/ERP5/bin/genbt5list b/product/ERP5/bin/genbt5list
index 835e2434fdfc15bad352f573067a0ef3bfa2451c..e931314aa02eb8e084ec4d2ede1ff48e061a35f3 100755
--- a/product/ERP5/bin/genbt5list
+++ b/product/ERP5/bin/genbt5list
@@ -216,14 +216,15 @@ def main(dir_list=None, **kw):
   for d in dir_list:
     bt5list = generateInformation(d, **kw).getvalue()
     # add pid in filename to avoid conflicts if several process calls genbt5list
-    d = os.path.join(d, 'bt5list.new.%i' % os.getpid())
+    destination_path =  os.path.join(d, 'bt5list')
+    temporary_path = destination_path + '.new.%i' % os.getpid()
     try:
-      with open(d, 'wb') as f:
+      with open(temporary_path, 'wb') as f:
         f.write(bt5list)
-      os.rename(d, 'bt5list')
+      os.rename(temporary_path, destination_path)
     finally:
       try:
-        os.remove(d)
+        os.remove(temporary_path)
       except OSError:
         pass