info-gnus-english
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: nnir with notmuch gives error; Possible solution!


From: Helmut Waitzmann
Subject: Re: nnir with notmuch gives error; Possible solution!
Date: Thu, 26 Mar 2020 20:16:24 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Eric Abrahamsen <eric@ericabrahamsen.net>:
physiculus <physiculus@gmail.com> writes:

But how could i change the string inside the filename from !2 to :2 ? Perhaps with dired, but i dont know how?

Dired has wdired-mode that allows you to edit file names in the dired buffer as though they were plain text, and then "commit" all the renames at once. If you have a small number of files to rename or they're all in the same directory that would be most straightforward. If these files are scattered through a very large number of directories you'll probably want to do it in the shell, probably with find and exec and mv.

As physiculus apparently uses a linux system, I assume, that "find" will be GNU "find", "ls" will be GNU "ls", and a "bash" will be available. 

  (
    cd -- /the/nndir/directory/hierarchy &&
    find . -depth -name '*!*' \
      ! -exec bash -c -- '
        curname="${1##*/}" && dir="${1%"$curname"}" &&
        newname="${curname//!/:}" &&
        if test -e "${dir}${newname}" ||
          test -L "${dir}${newname}"
        then
          # The file to be renamed to already exists!
          # What should be done?  Let the user decide:
          cd -- "$dir" &&
          printf %s\\n \
            '\''current subdirectory:'\'' \
            "$dir" \
            '\''The file to be renamed to,'\'' \
            "$newname" '\''already exists!'\'' \
            '\''Please enter shell commands to resolve'\'' \
            '\''that situation.  For your convenience,'\'' \
            '\''the current file'"'s"' name is in the'\'' \
            '\''positional parameter "$1", while the new'\'' \
            '\''one is in the positional parameter "$2".'\'' \
            '\''For example, try the commands'\'' \
            '\''  ls -QF1logd -- "$1" "$2"'\'' \
            and \
            '\''  mv -i -- "$1" "$2"'\'' \
            '\''Type the command "exit" when finished.'\'' &&
          ls -QFlogdU -- "$curname" "$newname" &&
          "${SHELL}" -sim -- "$curname" "$newname"
        else
          # REMOVE THE FOLLOWING LINE STARTING WITH "printf" TO
          # ACTUALLY LET THIS COMMAND MOVE FILES:
          printf '%q\n' \
          mv -- "${dir}${curname}" "${dir}${newname}"
        fi' bash \{\} \;
  )

Not tested, though, therefore the actual "mv" command will only be printed rather than executed.  See the comment written in capitals, above.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]