diff options
author | hut <hut@lavabit.com> | 2011-09-25 00:55:40 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2011-09-25 00:55:40 +0200 |
commit | 1c6485c6e0eae47be5e0ec19e46fa1a0058fe91e (patch) | |
tree | ef619140fade17a3ca84c522746d5a2f0c2a7ee2 | |
parent | 8d21b83ce6f77e3e348930e3ee45935917ee2e34 (diff) | |
parent | e7a32e04f095f195d5dcd2b929a63904a810ddfe (diff) | |
download | ranger-1c6485c6e0eae47be5e0ec19e46fa1a0058fe91e.tar.gz |
Merge branch 'rename' of https://github.com/DaPangus/ranger
-rw-r--r-- | ranger/core/actions.py | 2 | ||||
-rw-r--r-- | ranger/defaults/commands.py | 15 |
2 files changed, 13 insertions, 4 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py index c8dffa55..328d4365 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -841,6 +841,6 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware): src = src.path try: - os.rename(src, dest) + os.renames(src, dest) except OSError as err: self.notify(err) diff --git a/ranger/defaults/commands.py b/ranger/defaults/commands.py index f25abc19..a96c842c 100644 --- a/ranger/defaults/commands.py +++ b/ranger/defaults/commands.py @@ -638,11 +638,20 @@ class rename(Command): def execute(self): from ranger.fsobject import File + from os import access + from os.path import join + line = parse(self.line) - if not line.rest(1): + new_name = line.rest(1) + + if not new_name: return self.fm.notify('Syntax: rename <newname>', bad=True) - self.fm.rename(self.fm.env.cf, line.rest(1)) - f = File(line.rest(1)) + + if access(new_name, os.F_OK): + return self.fm.notify("Can't rename: file already exists!", bad=True) + + self.fm.rename(self.fm.env.cf, new_name) + f = File(new_name) self.fm.env.cwd.pointed_obj = f self.fm.env.cf = f |