Page 1 of 1

script request to quickly rename file with date

Posted: 10 Feb 2023 03:37
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'?

Re: script request to quickly rename file with date

Posted: 10 Feb 2023 07:24
by highend
renameitem(formatdate(, "yyyymmdd") . "_" . replace(trim(<clp>), " ", "_"));

Re: script request to quickly rename file with date

Posted: 10 Feb 2023 07:40
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.

Re: script request to quickly rename file with date

Posted: 10 Feb 2023 07:54
by highend
Show the button definition with the script part visible...

Re: script request to quickly rename file with date

Posted: 10 Feb 2023 08:17
by jupe
It seems like you are running the script with the script still on the clipboard.

Re: script request to quickly rename file with date

Posted: 10 Feb 2023 08:52
by bebotette
Thanks for all your input. It took me some tries to finally get the hang of it.

Thanks a lot! It works!