Hello - I apologize if this is elementary - I'm new to scripting - but does anyone have a script for truncating file names (in batch) to a certain length? For example:
npr_100550000__kip_ipx_1940137902_1234755987.mp3
to:
npr_100550000.mp3
(13 characters)
Many thanks,
Al
Script to batch truncate filenames
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: Script to batch truncate filenames
Hi and Welcome to XYplorer,
You can do it easily with regexp rename script posted previously by TheQwerty. If that doesnt work for you, then try the below script:
You can do it easily with regexp rename script posted previously by TheQwerty. If that doesnt work for you, then try the below script:
Code: Select all
//Truncate script
global $g_truncate;
input $g_truncate, remove characters after?, 13;
$selected = getinfo ("SelectedItemsPathNames", "|");
replace $selected, $selected, <curpath>\, ;
filter $selected;
sel 1;
sub "_eval";
"_eval"
$count = getinfo("CountSelected");
$eval = $count ==1 ? "_start" : "_end";
sub $eval;
"_start"
global $g_truncate;
substr $new, <curbase>, ,$g_truncate ;
rename b, $new;
sel +1;
sub "_eval"
"_end"
filter;
status "Done!";
-
thompsonao
- Posts: 2
- Joined: 13 Apr 2009 00:46
Re: Script to batch truncate filenames
Worked great - many thanks!
-AOT
-AOT
XYplorer Beta Club