2

As a former Microsoft Windows user, I'm used to using Ctrl+C and Ctrl+V on a file, which then creates a copy/copies of the same file.

Attempting this in Dolphin results in a prompt that the file already exists and that I should enter a different target file name. Can Dolphin be configured to match Microsoft's Windows behaviour?

Microsoft Windows creates example.txt - Copy, example.txt - Copy (2), example.txt - Copy (3) and so on without asking for an alternative filename.

  • What do you want should happen? Say you have example.txt. What should the copied file be named? Assume readers here aren't familiar with what Microsoft Windows does. – DK Bose Feb 15 at 13:08
  • 1
    AFAICT, there doesn't seem to be any option for altering Dolphin's behavior in the way you describe. However, if you're using a Linux distro with the KDE Plasma desktop environment you can do part of what you want by using Service Menus. When set up, you can right-click on a file and make a copy which will have, for example, a time-stamp appended to the end of the filename to distinguish it from the original. – DK Bose Feb 16 at 12:23
  • @DKBose: That's pretty much the answer I was looking for. I would accept this as an answer if there'd be the checkmark along your comment, so I was only able to upvote it. – lmoly Feb 16 at 18:32
  • Hi, I didn't post an answer initially because I was unsure whether a workaround would be acceptable. I've now posted an answer. – DK Bose Feb 17 at 2:34
2

Edit added on 20200322 relevant to a future version of Dolphin:

Dolphin has a new “Duplicate” feature that can be used to quickly create copies of selected items (me: Nate Graham, Dolphin 20.04.0)

Source


I too feel the need to sometimes copy/paste the same file in its current location. Obviously, the filename has to be modified somewhat. Dolphin does not automatically provide names such as example.txt - Copy, example.txt - Copy (2), example.txt - Copy (3) to distinguish copies from the original but provides an interface allowing the user to modify the filename of each copy made.

I prefer the simpler route of adding timestamps with the help of Dolphin Service Menus as described below.

Consider a file titled out.mp4. The image below shows the original and a few copies with time stamps.

Dolphin showing timestamped copies

Making timestamped copies using Service Menus in Dolphin.

Service Menus allow users to customize the context menu of Dolphin to provide additional features.

Create /home/dkb/.local/share/kservices5/ServiceMenus (where dkb is to be changed appropriately).

In there, create an empty text file named copy-with-stamp.desktop

Paste in the following content:

[Desktop Action copy-with-stamp]
Exec=cp-with-timestamp.sh %U
Name=Add timestamp as suffix
Icon=edit-copy

[Desktop Entry]
Actions=copy-with-stamp
ServiceTypes=KonqPopupMenu/Plugin
MimeType=all/all
Type=Service
X-KDE-Priority=TopLevel

and save the file as plain text.

Notice Exec=cp-with-timestamp.sh %U in which cp-with-timestamp.sh is an executable with the following content:

#!/bin/bash

cp "$@" "$@"-"$(date +%Y%m%d%H%M%S)"

You can make the timestamp more or less elaborate depending on your needs. man date explains how. But you must ensure that cp-with-timestamp.sh is executable (which can be done in Dolphin itself) and stored in your $PATH (or provide the entire path and filename in the Exec=line). I have ~/bin in my $PATH and so I keep cp-with-timestamp.sh in ~/bin.

Once you've created both the .desktop file and the executable script, you can right-click on any file in your home folder and see the context menu option:

Dolphin's modified context menu:

Note that my context menu isn't standard: I've removed some things, added others.


More reading

  • There's a long thread on Service Menus at Kubuntu Forums

  • People develop and contribute Service Menus over at the KDE Store. One caution is to make sure you're considering Service Menus relevant to your KDE Plasma version.

  • For people coming from other operating systems, safe names for files and folders maybe worth a read so that the implications of using spaces, ', (, ), etc are well understood.

| improve this answer | |

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.