Here is the code to rename the file after getting the chars.
Incl. a few other ideas.
* remove n chars from start
* remove n chars from end
* keep n chars from start, remove the rest
* keep n chars from end, remove the rest
* simple preview
Not that elegant implemented but the code should work.
Take what you want and drop the rest.
But for complicated modification you should rather use an real renamer like Siren.
See >>
http://www.xyplorer.com/xyfc/viewtopic. ... 059#p57059
Or use File > Rename Special > RegEx Rename...
where you get an better preview overview.
Code: Select all
//// Get the first or the last few chars to rename the file to.
end (get("CountSelected") == 0, "Nothing selected");
$CharAmount = input("Enter no of characters.<crlf>Use an leading minus - to get from the end of string.",,-3);
$Methode = inputselect(Choose methode for that $CharAmount chars:, "+RemoveThisChars_KeepRest|KeepThisChars_RemoveRest", , 2);
$SelectedItems = report("{BaseName}?{Ext}|",1);
$out="";
foreach($Item, $SelectedItems) {
if($Item == "") { break; }
if(exists(replace("<curpath>\$Item","?",".")) != 1) { continue; } //no folders
$base = gettoken($Item, 1, "?");
$exte = gettoken($Item, 2, "?");
if ($exte==""){continue;}
if ($Methode=="RemoveThisChars_KeepRest"){
if strpos($CharAmount, "-") == -1){
$GetChars = substr($base, $CharAmount);
}else{
$GetChars = substr($base, 0, $CharAmount);
}
}
if ($Methode=="KeepThisChars_RemoveRest"){
if strpos($CharAmount, "-") == -1){
$GetChars = substr($base, 0, $CharAmount);
}else{
$GetChars = substr($base, $CharAmount);
}
}
$oldname = replace($Item, "?", ".");
$SKIP = input("Rename or cancel? - $Methode", , "$oldname<crlf>$GetChars.$exte", m, "SKIP");
if ($SKIP=="SKIP"){continue;}
renameitem( "$GetChars.$exte", $oldname, 0, "_001" );
}