4

When copying or moving a file/files in a dired buffer sometimes the file already exists in the location one is moving or copying to. Emacs then prompts the user and asks whether to "overwrite" the existing file or not. One is given these options: y/n/!/q or C-h. However, one cannot tell if there is any difference in size (or date) between the two files, the one already in the directory and the one being copied. This is crucial information, for at times one would like to keep a larger file or a smaller one. Is there a way of displaying this information or not?

migrated from superuser.com Dec 31 '18 at 16:54

This question came from our site for computer enthusiasts and power users.

  • If the file already exists in the Dired directory then its date and size are also available there. This might require you to use g to refresh the listing, or ( to unhide details. And it might require you to use search, to get to that file in the listing. If the target directory is not already shown in a Dired buffer then it will require you to visit that directory. And you'll probably need to first quit the copy/move/etc. operation, to check the info, and then relaunch the operation. – Drew Dec 31 '18 at 19:02
  • You could modify the message and prompt, to add an option to list the file(s) in question, including their details. – Drew Dec 31 '18 at 19:03
2

OK, I've just updated Dired+ to help with this.

Now, when you're told there is an overwrite conflict and asked what to do about it, in addition to the standard actions of hitting y, n, q or ! , you can hit l, which pops up a window that lists details about the file(s): last modification time and permissions. Then you can hit one of the other keys with your choice of action.

The library is here: https://www.emacswiki.org/emacs/download/dired%2b.el.

  • This is a most helpful addition to Dired+. Thank you. It does not however solve the problem of disparate file sizes. – devcom Jan 11 at 7:59
  • 1
    In cases where both source and destination file are available to the calling function, l lists them both. E.g., when dired-get-files calls diredp-y-or-n-files-p to ask "Use marked (instead of all) in subdir Dired buffers?" and you hit l you see the sizes (and permissions) for both files (which solves the size "problem", I think). In some other contexts only the destination file is available to the function that queries you, so l can only list its details. In code you write, you can use diredp-list-files anytime to list details of any set of files. – Drew Jan 11 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.