diff options
author | Arun Prakash Jana <engineerarun@gmail.com> | 2018-02-24 19:46:58 +0530 |
---|---|---|
committer | Arun Prakash Jana <engineerarun@gmail.com> | 2018-02-24 19:46:58 +0530 |
commit | ee733a39b1f82088d607d72b0ab492770a723845 (patch) | |
tree | 456a51f9fdb5c4511164667215cb76315f37fbec /nnn.c | |
parent | 63512152df2b98fc1b1192e7f028afd4bfb87057 (diff) | |
download | nnn-ee733a39b1f82088d607d72b0ab492770a723845.tar.gz |
Support batch file rename in vidir
Diffstat (limited to 'nnn.c')
-rw-r--r-- | nnn.c | 35 |
1 files changed, 33 insertions, 2 deletions
@@ -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; |