mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +00:00
Support batch file rename in vidir
This commit is contained in:
parent
63512152df
commit
ee733a39b1
|
@ -5,6 +5,7 @@ What's in?
|
|||
- Copy multiple file paths
|
||||
- Copy file paths when X is unavailable
|
||||
- Optionally quote individual file paths with single quotes on copy
|
||||
- Batch rename files in vidir from [moreutils](https://joeyh.name/code/moreutils/)
|
||||
- Use ISO 8601 date format in file details
|
||||
- New/changed/remapped shortcuts:
|
||||
- <kbd>^B</kbd> - show bookmark prompt (replaces <kbd>b</kbd>)
|
||||
|
|
|
@ -109,6 +109,7 @@ Have fun with it! PRs are welcome. Check out [#1](https://github.com/jarun/nnn/i
|
|||
- Sort by file name, modification time, size
|
||||
- Convenience
|
||||
- Create, rename files and directories
|
||||
- Batch rename current directory entries in vidir (from moreutils)
|
||||
- Spawn SHELL (fallback sh) in the current directory
|
||||
- Copy absolute file paths with/without X (*easy* shell integration)
|
||||
- Change directory at exit (*easy* shell integration)
|
||||
|
@ -238,6 +239,7 @@ optional arguments:
|
|||
M | Full media info
|
||||
n | Create new
|
||||
^R | Rename entry
|
||||
R | Rename dir entries
|
||||
s | Toggle sort by size
|
||||
S, ^J | Toggle du mode
|
||||
t | Toggle sort by mtime
|
||||
|
@ -303,6 +305,7 @@ The following abbreviations are used in the detail view:
|
|||
export NNN_DE_FILE_MANAGER=nautilus
|
||||
- [mediainfo](https://mediaarea.net/en/MediaInfo) (or [exiftool](https://sno.phy.queensu.ca/~phil/exiftool/), if specified) is required to view media information
|
||||
- [atool](http://www.nongnu.org/atool/) is required to list and extract archives
|
||||
- vidir from [moreutils](https://joeyh.name/code/moreutils/) is used to batch rename entries in current directory
|
||||
|
||||
#### Help
|
||||
|
||||
|
|
2
nnn.1
2
nnn.1
|
@ -82,6 +82,8 @@ Show full media info
|
|||
Create a new file or directory
|
||||
.It Ic ^R
|
||||
Rename selected entry
|
||||
.It Ic R
|
||||
Rename directory entries
|
||||
.It Ic s
|
||||
Toggle sort by file size
|
||||
.It Ic S, ^J
|
||||
|
|
35
nnn.c
35
nnn.c
|
@ -281,7 +281,8 @@ static char * const utils[] = {
|
|||
"xdg-open",
|
||||
#endif
|
||||
"nlay",
|
||||
"atool"
|
||||
"atool",
|
||||
"vidir"
|
||||
};
|
||||
|
||||
/* Common strings */
|
||||
|
@ -641,7 +642,7 @@ appendfilepath(const char *path, const size_t len)
|
|||
copybuflen += PATH_MAX;
|
||||
pcopybuf = xrealloc(pcopybuf, copybuflen);
|
||||
if (!pcopybuf) {
|
||||
printmsg("no memory!\n");
|
||||
printmsg("no memory!");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1867,6 +1868,7 @@ show_help(char *path)
|
|||
"eM | Full media info\n"
|
||||
"en | Create new\n"
|
||||
"d^R | Rename entry\n"
|
||||
"eR | Rename dir entries\n"
|
||||
"es | Toggle sort by size\n"
|
||||
"aS, ^J | Toggle du mode\n"
|
||||
"et | Toggle sort by mtime\n"
|
||||
|
@ -3070,6 +3072,35 @@ nochange:
|
|||
close(fd);
|
||||
xstrlcpy(oldname, tmp, NAME_MAX + 1);
|
||||
goto begin;
|
||||
case SEL_RENAMEALL:
|
||||
if (!get_output(g_buf, MAX_CMD_LEN, "which", utils[5], NULL, 0)) {
|
||||
printmsg("vidir missing");
|
||||
goto nochange;
|
||||
}
|
||||
|
||||
/* Save the program start dir */
|
||||
tmp = getcwd(newpath, PATH_MAX);
|
||||
if (tmp == NULL) {
|
||||
printwarn();
|
||||
goto nochange;
|
||||
}
|
||||
|
||||
/* Switch to current path for readline(3) */
|
||||
if (chdir(path) == -1) {
|
||||
printwarn();
|
||||
goto nochange;
|
||||
}
|
||||
|
||||
spawn(utils[5], ".", NULL, NULL, F_NORMAL);
|
||||
|
||||
/* Change back to program start dir */
|
||||
if (chdir(newpath) == -1)
|
||||
printwarn();
|
||||
|
||||
/* Save current */
|
||||
if (ndents > 0)
|
||||
copycurname();
|
||||
goto begin;
|
||||
case SEL_HELP:
|
||||
show_help(path);
|
||||
break;
|
||||
|
|
3
nnn.h
3
nnn.h
|
@ -39,6 +39,7 @@ enum action {
|
|||
SEL_OPEN,
|
||||
SEL_NEW,
|
||||
SEL_RENAME,
|
||||
SEL_RENAMEALL,
|
||||
SEL_HELP,
|
||||
SEL_RUN,
|
||||
SEL_RUNARG,
|
||||
|
@ -158,6 +159,8 @@ static struct key bindings[] = {
|
|||
/* Show rename prompt */
|
||||
{ CONTROL('R'), SEL_RENAME, "", "" },
|
||||
{ KEY_F(2), SEL_RENAME, "", "" }, /* Undocumented */
|
||||
/* Rename contents of current dir */
|
||||
{ 'R', SEL_RENAMEALL, "", "" },
|
||||
/* Show help */
|
||||
{ '?', SEL_HELP, "", "" },
|
||||
/* Run command */
|
||||
|
|
Loading…
Reference in a new issue