Page 1 of 1
Trim file name on left side
Posted: 30 Nov 2017 16:48
by MickeyVee
Hi,
Novice to scripting. I need to trim 2 characters on the left side of a filename. What's the syntax and where do I execute it? Also, can the code be used when using F2 (Batch rename)?
Thanks for your help!

Re: Trim file name on left side
Posted: 30 Nov 2017 17:04
by highend
Code: Select all
renameitem(substr(gpc(, "base"), 2), , 1);
Put it on a button, a catalog item, a user defined command (and add a keyboard shortcut to it),
whatever you like...
Code: Select all
Also, can the code be used when using F2
Nope
Re: Trim file name on left side
Posted: 30 Nov 2017 20:38
by MickeyVee
Hey Highend,
Thanks for the help.

Re: Trim file name on left side
Posted: 30 Nov 2017 22:37
by highend
For multiple items:
Code: Select all
foreach($item, <get SelectedItemsPathNames |>, , "e") { renameitem(substr(gpc($item, "base"), 2), $item, 1); }
Re: Trim file name on left side
Posted: 04 Nov 2019 04:32
by Sleeve45
foreach($item, <get SelectedItemsPathNames |>, , "e") { renameitem(substr(gpc($item, "base"), 4), $item, 1); only worked on the first filename because the closing brace ("}") is missing. Now it works great. Thanks for the script.

Re: Trim file name on left side
Posted: 04 Nov 2019 07:36
by RalphM
Welcome to the forum!
The closing bracket wasn't missing, thus the horizontal scrollbar and that's also where the "Select All" button comes in handy.