Trim file name on left side

Discuss and share scripts and script files...
Post Reply
MickeyVee
Posts: 5
Joined: 24 Apr 2016 17:50

Trim file name on left side

Post 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! 8)

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Trim file name on left side

Post 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
One of my scripts helped you out? Please donate via Paypal

MickeyVee
Posts: 5
Joined: 24 Apr 2016 17:50

Re: Trim file name on left side

Post by MickeyVee »

Hey Highend,
Thanks for the help. 8) :beer:

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Trim file name on left side

Post by highend »

For multiple items:

Code: Select all

foreach($item, <get SelectedItemsPathNames |>, , "e") { renameitem(substr(gpc($item, "base"), 2), $item, 1); }
One of my scripts helped you out? Please donate via Paypal

Sleeve45
Posts: 1
Joined: 04 Nov 2019 04:13

Re: Trim file name on left side

Post 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. :)

RalphM
Posts: 1932
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Re: Trim file name on left side

Post 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.
Ralph :)
(OS: W11 22H2 Home x64 - XY: Current beta - Office 2019 32-bit - Display: 1920x1080 @ 125%)

Post Reply