SpecialRename2

Discuss and share scripts and script files...
Post Reply
bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

SpecialRename2

Post by bdeshi »

Instead of picking a premeditated Special Rename option and then lamenting that another choice would've been better, you can now simply choose a mode on-the-fly.
This script unites these special rename modes: regexp, batch, search/replace, keep characters, set extension.
SpecialRename2.xys
Usage:
  • Select some items and run this script.
  • Enter rename pattern in whichever mode you want. Usual rules and syntax of individual modes apply.
  • Now simply prefix the whole pattern with a single character (case-insensitive) to determine the mode:
    r : regexp, b : batch rename, s : search/replace, k : keep characters, e : set extension.
  • Additionally, to get a preview before the actual rename(s), prefix the whole pattern+modechar with: p
  • Examples: batchrename without preview: b*-<date mmyy
    >
                    search-&-replace "-" with "_" : ps-/_
                    regexp rename with preview : r\s\d+.([^.]+)$ > .$1
                    keep characters with preview: pk&_>-
  • Assign this script to a quick shortcut via UDC (I myself have assigned CTRL+F2)
Issues:
  • cancelling rename from preview pops up error dialog.
========

Code: Select all

/*SpecialRename2/SammaySarkar/v1/04-Mar-2015 6:49:40 AMZ/http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=13497*/
 $input   = input("enter [p for preview] modeswitch char, then pattern<crlf>modes: b,r,s,k,e", 
            'batch rename without preview: b*-<datem yyyymmdd>'.<crlf>.
            'search-&-replace with preview: s /_'
            );
 $preview = substr($input, 0, 1) == 'p' ? 'p' : '';
 $mode    = substr($input, $preview ? 1 : 0, 1);
 $pattern = substr($input, $preview ? 2 : 1);
 //msg $pattern<crlf>$mode<crlf>$preview;

 if ($mode LikeI [brske]){
  rename $mode, $pattern, $preview, <get selecteditemspathnames |>;
 }
[/size]
To see the attached files, you need to log into the forum.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

Post Reply