Skip to content

Commit

Permalink
config/commands.py: fix bulkrename on OSX 10.8, fixes ranger#136
Browse files Browse the repository at this point in the history
  • Loading branch information
hut committed Dec 10, 2014
1 parent 1897ee5 commit 7d38194
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ranger/config/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,20 +793,22 @@ def execute(self):

# 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
Expand Down

0 comments on commit 7d38194

Please sign in to comment.