Need help creating a right click menu with new folder with dated

I followed the instructions for creating a new menu for creating a new folder with date but could not get it to work. It shows up in right click but does not do anything.

[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin,text/*,application/x-desktop
MimeType=all/all;
Actions=DateFolder;
Terminal=false
X-KDE-Priority=TopLevel

[Desktop Action DateFolder]
Name=New folder with date
Icon=folder-new
Exec=bash -c "mkdir $(date +"%Y-%m-%d")"

I tried this one in different ways. Nogo. I have no idea why that is. Tried commands, script…nothing. Except if you run it from a terminal. The command is just fine but for some reason it doesn’t start from a servicemenu.

It could be that this is because the Desktop Entry Specification for Exec says:

Field codes must not be used inside a quoted argument, the result of field code expansion inside a quoted argument is undefined.

And it looks like %Y is not among the recognized field codes, but %m and %d are and are deprecated. If I run dolphin from console I can see it fail when trying to run this action with:

mkdir: directory »2023–/home/« could not be created

Where “/home/” is what %d expands to in this case and it is apparently tha parent directory of the folder/file you right-click on.

Edit: I found some kind of…um…patch. If you add inode/directory; to the mimetypes, like:

[Desktop Entry]
Actions=dateFolder;
Icon=folder-new
MimeType=all/allfiles;inode/directory;
ServiceTypes=KonqPopupMenu/Plugin
Terminal=false
Type=Service
X-KDE-Priority=TopLevel
X-KDE-StartupNotify=false

…you can do it by right clicking an existing folder/whatever. Mind you, I directed the exec to a bash script .

#!/bin/sh
mkdir $(date +“%d-%m-%Y”)

This is what I have and it is creating the directory in Home directory only and not where the right click was made.

[Desktop Entry]
Actions=dateFolder;
Icon=folder-new
MimeType=all/allfiles;inode/directory;
ServiceTypes=KonqPopupMenu/Plugin
Terminal=false
Type=Service
X-KDE-Priority=TopLevel
X-KDE-StartupNotify=false

[Desktop Action dateFolder]
Name=New folder with date
Icon=folder-new
Exec=/home/xxx/.local/share/kservices5/ServiceMenus/datefolder.sh

I suggest you make that little script first and point the exec to the script. That will create the date folder in the directory you’re in. However, you can change the script a bit so you can place the folder wherever you want using a kdialog, regardless where the folder was created.
Script:
#!/bin/sh
mkdir $(date +“%d-%m-%Y”) &&
kdemv5 $(date +“%d-%m-%Y”) $(kdialog --getexistingdirectory)

That will give you this:

For example: The date folder was created on an image file in ~/Downloads and moved to my desktop.

For some reason I could not get it to work. If I right click in Documents folder it is creating a folder in Home and not moving the folder to Documents folder.

A bit of Picasso…

Makes it work in/on any directory, on any type of file.

Thanks it works now, I wish it could be done without the Open Dialogue.

Then don’t use it. Without the kdmv part in the script, the folder is created in the directory you’re at. It always is, the kdialog just allows you to move it anywhere you like. Just leave:
#!/bin/sh
mkdir $(date +“%d-%m-%Y”)

…in the script.

I understand, it is not prefect but works.

Well, then I don’t understand what you would consider perfect. I can create this date folder anywhere on anything. It doesn’t get created in home but in the directory I’m at. And if I want to move it I can always use the kdialog. Not sure what else can be done to make it better.

This is actually not happening with me on Kubuntu. Right click menu creates the date folder in home directory and then the Dialog window opens and I select the folder and it moves the date folder there.

But I can live with that, it is good enough for me.

I placed the script in the same directory, ServiceMenus. No prob whatsoever. Something must be wrong. You’re sure you’re using the right script? Cause from what you say, the command cd’s to ~/ first.

I have no idea everything is identical, must be a Kubuntu thing. But dont worry about it, its not a big deal.