script request to quickly rename file with date

Discuss and share scripts and script files...
Post Reply
bebotette
Posts: 4
Joined: 01 Apr 2022 04:29

script request to quickly rename file with date

Post by bebotette »

Hello. I wish to have the following steps done to help me rename files/folders in a specific way:

Example text from clipboard to be fetched: This is a Christmas gift
Output I wanted when renaming a file/folder: 20230210_This_is_a_Christmas_gift
-where the date is the date today
-where all spaces are converted to underscores "_"
-where the text case is not affected
-where the spaces at the end of the clipboard (assuming the text in the clipboard has extra spaces after the word "gift") are removed

Thank you!

PS: does this fall under 'Rename' or 'Run Script'?

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: script request to quickly rename file with date

Post by highend »

renameitem(formatdate(, "yyyymmdd") . "_" . replace(trim(<clp>), " ", "_"));
One of my scripts helped you out? Please donate via Paypal

bebotette
Posts: 4
Joined: 01 Apr 2022 04:29

Re: script request to quickly rename file with date

Post by bebotette »

Thanks. Please tell me if I did the right steps because I'm getting an error (attached):
1. Went to User > Managed User-Defined Commands
2. Under category, I clicked 'Run Script'
3. Added a new command, then on the script field, I pasted the one you provided.

Now when I click on a file and trigger this command, I get some error. Please help.
Attachments
ss_2023-02-10_14-33-04.png
ss_2023-02-10_14-33-04.png (334.13 KiB) Viewed 495 times

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: script request to quickly rename file with date

Post by highend »

Show the button definition with the script part visible...
One of my scripts helped you out? Please donate via Paypal

jupe
Posts: 2800
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: script request to quickly rename file with date

Post by jupe »

It seems like you are running the script with the script still on the clipboard.

bebotette
Posts: 4
Joined: 01 Apr 2022 04:29

Re: script request to quickly rename file with date

Post by bebotette »

Thanks for all your input. It took me some tries to finally get the hang of it.

Thanks a lot! It works!

Post Reply