Page 1 of 1

I would like to change the default name of newly created files and directories from Thunar

Posted: Tue Dec 12, 2023 2:49 pm
by Wirtualny
I would like every new file I create in MX Linux XFCE using the right mouse button to have a default name in the form of a current date in YYYYMMDD format followed by my name instead of the name "New file". Similarly, I would like every new directory I create to have a default name in the form of a date in the format YYYYMMDD followed by my name instead of "New Directory".

For example, every new file or directory created today should have the default name offered by Thunar "20231212 Wirtualny".

Is this achievable?

Re: I would like to change the default name of newly created files and directories from Thunar

Posted: Tue Dec 12, 2023 3:35 pm
by dolphin_oracle
You can't change the default thunar action, but you can create a custom right click action for that. You can even give it a shortcut key combo if you like.

the command would be something like

Code: Select all

touch "$(date +%Y%m%d) $USER"

Re: I would like to change the default name of newly created files and directories from Thunar  [Solved]

Posted: Tue Dec 12, 2023 3:54 pm
by CharlesV
I have something very similar to that, but I could never get the touch command to work from my custom action.

I created a script ( LogDate.sh ) , and then set a custom action to run that. Then in LogDate.sh I have the following:

Code: Select all

touch "log_$(date +"%Y%m%d_%I%M%p").log"
This allows me to not have to change the action, only the LogDate.sh script and i can add / modify any way I want.

If OP wanted, then a NewFile.sh with the following content should work:

Code: Select all

touch "$(date +"%Y%m%d_%I%M%p Wirtualny")"
( remove the _%I%M%p if you dont want time )

Then, Thunar | Custom Actions
create a new Custom Action and set the NewFile.sh as the command, and Name it something like New File.

Right click on white space in thunar and choose the New File entry approx halfway down the list.

Re: I would like to change the default name of newly created files and directories from Thunar

Posted: Tue Dec 12, 2023 4:42 pm
by Charlie Brown
...+

Code: Select all

mkdir "$(date +%Y%m%d) $USER"

Re: I would like to change the default name of newly created files and directories from Thunar

Posted: Wed Dec 13, 2023 7:35 pm
by Wirtualny
Thank you very much! :)

It's greater than I have expected!