summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lepus.uberspace.de>2014-12-10 19:56:03 +0100
committerhut <hut@lepus.uberspace.de>2014-12-10 19:56:03 +0100
commit7d3819442f41e0680b798f39b63e2bd5228e1474 (patch)
tree8c4862a6d7e4aaaf549719e7269ce034574d595d
parent1897ee5777c2c9fc65f0c6bf68c55aad846dbcba (diff)
downloadranger-7d3819442f41e0680b798f39b63e2bd5228e1474.tar.gz
config/commands.py: fix bulkrename on OSX 10.8, fixes #136
Thanks to Ingo Lindholm for the fix:
http://lists.gnu.org/archive/html/ranger-users/2013-09/msg00001.html
-rw-r--r--ranger/config/commands.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index 9a8a7934..f91154ff 100644
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -793,20 +793,22 @@ class bulkrename(Command):
 
         # Create and edit the file list
         filenames = [f.basename for f in self.fm.thistab.get_selection()]
-        listfile = tempfile.NamedTemporaryFile()
+        listfile = tempfile.NamedTemporaryFile(delete=False)
+        listpath = listfile.name
 
         if py3:
             listfile.write("\n".join(filenames).encode("utf-8"))
         else:
             listfile.write("\n".join(filenames))
-        listfile.flush()
-        self.fm.execute_file([File(listfile.name)], app='editor')
-        listfile.seek(0)
+        listfile.close()
+        self.fm.execute_file([File(listpath)], app='editor')
+        listfile = open(listpath, 'r')
         if py3:
             new_filenames = listfile.read().decode("utf-8").split("\n")
         else:
             new_filenames = listfile.read().split("\n")
         listfile.close()
+        os.unlink(listpath)
         if all(a == b for a, b in zip(filenames, new_filenames)):
             self.fm.notify("No renaming to be done!")
             return