How to move directories in Ranger?
Solution 1
I never needed ranger's native move
command with being able to use the mv
command on the ranger command line, to move the selected file or directory to a given directory, e.g.:
shell -f mv %f /foo/bar
where %f
is the ranger macro for highlighted files, and %s
would be for all the selected.
The option -f
forks the operation so that the ranger session is not interrupted by a long file process.
You can summon the comand line with s, ! or @.
Another way, especially if you have many copies/moves to make, is to open another tab in ranger, with gn
and cd to the directory you want to copy/move the files to. Then return to the first tab to select files and use the ranger macro for the next tab %D
, to move files to, like,
shell -f mv %f %D
But that actually only saves you from hitting yy Tab dd Tab
. To be honest I usually switch tab and dd
.
I set up key-bindings in the rc.conf file like so,
#sync sel'd into dir on next tab
map ytt shell -f rsync -rult %s %D
#sync sel'd from dir on next tab
map yff shell -f rsync -rult %S %d
#sync sel'd into dir on next tab :incl referred files
map ytr shell -f rsync -ruLt %s %D
#sync sel'd from dir on next tab :incl referred files
map yfr shell -f rsync -ruLt %S %d
#move sel'd into dir on next tab
map dtt shell -f mv %s %D
#move sel'd from dir on next tab
map dff shell -f mv %S %d
Note that %S
is the macro for the selected files on the next tab.
%d
is the macro for the directory path of current tab.
And some others,
#copy sel'd into h'd dir
map pc shell -f rsync -rut %s %d/%f/
#move sel'd into h'd dir
map pm shell -f mv -u %s %d/%f
#copy buffer into h'd dir
map pds shell -f rsync -rult %c %d/%f/
#move buffer into h'd dir
map pdm shell -f mv -u %c %d/%f
#sync buffer'd files into curr dir :links only
map ps shell -f rsync -rult %c %d
Where %c
is the ranger macro for files held in the copy/cut buffer.
Files are easily added to the buffer with yy
, to yank, or ya
, to add to the copy buffer. Similarly, with dd
, to cut, or da
, to add to the cut buffer.
See my other key-mappings here
Solution 2
mozerella mentions:
Files are easily added to the buffer with yy, to yank, or ya, to add to the copy buffer. Similarly, with dd, to cut, or da, to add to the cut buffer.
I've found the method:
- dd on the directory -- Cut
- navigate to new directory
- pp -- Paste
applies to directories as well.
Related videos on Youtube
Admin
Updated on September 18, 2022Comments
-
Admin almost 2 years
I'm using Ranger file manager.
I want to move selected (
mark
ed) directories to the path provided.I've been moving directories using
dd
andpp
but it requires the user to go to the destination directory to "paste" them into.There's a undocumented
move
command which I don't know how to use.And I also guess it may be done through external shell command somehow, but I want to do it natively through the
move
command.-
n8te over 7 yearsYou can move directories with the same shell command you normally use to move directories. Within Ranger, just enter ! and then type your shell command.
-
Admin over 7 yearsThanks, but I'd like more to do it natively given that
move
command is available and as it would be easier I think.
-
-
Admin over 7 yearsThanks! I'll take these into account. But one thing that makes me wander the most is the actual purpose of the 'move' command present natively in range? It's not doing anything it seems.
-
Scott - Слава Україні about 5 yearsYou fault the other answer for not getting to the point, but then you clutter yours with talk about
sudo su
?