would like to have, please:
keep n characters from beginning
keep n characters from end
delete n characters from beginning
delete n characters from end
batch rename with n chars
batch rename with n chars
[AHK] redirecting Windows Explorer to XY, [XYS] Mini Tree with open tabs (cur loc expanded, tab folders highlighted), [AHK] customInlineRenameKeys, [AHK] clipboardHelper_and_XYEscToList
Re: batch rename with n chars
obviously this wish is not supported or did I miss a way of how it can be done already????
It is more or less standard in many other proggies capeable or batch renaming, i.e. "FreeCommander" or stand-alone-batch-renamers like "Advanced renamer".
But ok, if this should not be then I would like to ask: Please give me the option to use string-altering methods like substr() on the filename. Thank you.
(I know I could build a whole script myself using renameitem() but then I do have to program the whole batch part on my own and I dont have the preview.)
It is more or less standard in many other proggies capeable or batch renaming, i.e. "FreeCommander" or stand-alone-batch-renamers like "Advanced renamer".
But ok, if this should not be then I would like to ask: Please give me the option to use string-altering methods like substr() on the filename. Thank you.
(I know I could build a whole script myself using renameitem() but then I do have to program the whole batch part on my own and I dont have the preview.)
Last edited by autocart on 11 Apr 2014 21:06, edited 1 time in total.
[AHK] redirecting Windows Explorer to XY, [XYS] Mini Tree with open tabs (cur loc expanded, tab folders highlighted), [AHK] customInlineRenameKeys, [AHK] clipboardHelper_and_XYEscToList
-
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: batch rename with n chars
Please provide sample input/output for each, if script is an option for you.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Re: batch rename with n chars
I am not exactly sure, but I think u are asking for examples. That could be a lot though, i.e. any string that is reoccuring at the beginning or end of a bunch of files and that I want to get rid of. Technically I can do that with search/replace but if I want to make sure that i do not accidently delete part of a filename if it should contain this substring a second time then I would have to go by the length of the string from a starting position (mostly beginning or end).
[AHK] redirecting Windows Explorer to XY, [XYS] Mini Tree with open tabs (cur loc expanded, tab folders highlighted), [AHK] customInlineRenameKeys, [AHK] clipboardHelper_and_XYEscToList
Re: batch rename with n chars Rename RegEx Regular Expressio
autocart wrote:would like to have, please:
keep n characters from beginning
keep n characters from end
delete n characters from beginning
delete n characters from end
You could do that by utilizing Regular Expressions.
For example:
- Match first four signs: .{4}
- Match the rest of the name: .+
Now use parentheses (...) to capture what you have matched:
- Match first four signs: (.{4})
- Match the rest of the name: (.+)
Then replace with the wanted ()-matching group: $1 or $2, while dropping the other.
That way you can achieve what you are after.
----------------------------------
With XYPlorer RegEx Rename you would use this like this:
keep 4 characters from beginning (here introduced a third group to match the extension additionally )
(.{4})(.+)(\..+) > $1$3
keep 4 characters from end ( 4 to keep, plus dot plus 3 signs extension = 8 )
(.+)(.{8}) > $2
OR
(.+)(.{4})(\..+) > $2$3
delete 4 characters from beginning
(.{4})(.+) > $2
delete 4 characters from end
(.+)(.{4})(\..+) > $1$3
Note: this are simple regexes.
For files names with dots we have to make them more error save.
And if you learn how to use RegEx you can improve that expressions even more and more.
- - -
If you need more, you can always incorporate a third-party,
standalone portable, free renaming tool like SIREN:
Use Siren with XYplorer
http://scarabee-software.net/forum/viewtopic.php?id=228
Download:
http://scarabee-software.net/en/download.html
I am still using the old v2 due to its small file size ;-)
And for even more advantage tasks (better multi-steps handling, PascalScript), use den4b ReNamer. (http://www.den4b.com/?x=products)
.
Re: batch rename with n chars
THX, Stefan!!
Thx again.
EDIT:
OK, anyway trying to make it more safe and make it work with filenames with or w/o extension and with "too short" file names:
keep 4 characters from beginning
1.attempt:^(.{4})(.+?)(\.[^.]+)?$ > $1$3
current attempt:
^(.{4})(.*)(\.[^.]+)$|^([^.]{4})([^.]*)$ > $1$3$4
keep 4 characters from end
1.attempt:^(.+?)(.{4})(\.[^.]+)?$ > $2$3
current attempt:
^(.*)(.{4})(\.[^.]+)$|^([^.]*)([^.]{4})$ > $2$3$5
delete 4 characters from beginning
1.attempt:(.{4})(.+) > $2
current attempt:
^(.{4})(.+)(\.[^.]+)$|^([^.]{4})([^.]+)$ > $2$3$5
delete 4 characters from end
1.attempt:^(.+?)(.{4})(\.[^.]+)?$ > $1$3
current attempt:
^(.+)(.{4})(\.[^.]+)$|^([^.]+)([^.]{4})$ > $1$3$4
or possibly
^(.+?)(.{4})??(\.[^.]+)?$ > $1$3
And then one could add these to the user commands with the result as in the picture. In the following preview the pattern can still be edited i.e. in order to set the number of 4 chars to 3 or 5.
I tried various filename formats with dots. Your "simple" regexes always worked perfectly as intended. I could not find any format where it would have not worked.Stefan wrote:Note: this are simple regexes.
For files names with dots we have to make them more error save.
Thx again.
EDIT:
OK, anyway trying to make it more safe and make it work with filenames with or w/o extension and with "too short" file names:
keep 4 characters from beginning
1.attempt:
current attempt:
^(.{4})(.*)(\.[^.]+)$|^([^.]{4})([^.]*)$ > $1$3$4
keep 4 characters from end
1.attempt:
current attempt:
^(.*)(.{4})(\.[^.]+)$|^([^.]*)([^.]{4})$ > $2$3$5
delete 4 characters from beginning
1.attempt:
current attempt:
^(.{4})(.+)(\.[^.]+)$|^([^.]{4})([^.]+)$ > $2$3$5
delete 4 characters from end
1.attempt:
current attempt:
^(.+)(.{4})(\.[^.]+)$|^([^.]+)([^.]{4})$ > $1$3$4
or possibly
^(.+?)(.{4})??(\.[^.]+)?$ > $1$3
And then one could add these to the user commands with the result as in the picture. In the following preview the pattern can still be edited i.e. in order to set the number of 4 chars to 3 or 5.
- Attachments
-
- user-rename-commands.jpg (45.71 KiB) Viewed 3077 times
[AHK] redirecting Windows Explorer to XY, [XYS] Mini Tree with open tabs (cur loc expanded, tab folders highlighted), [AHK] customInlineRenameKeys, [AHK] clipboardHelper_and_XYEscToList
Re: batch rename with n chars
UPDATE:
Currently used code - with dynamic user input:
(Copy and Use at own risk!)
1) Delete X characters from the end:
2) Delete X characters from the beginning:
3) Keep X chararcters from the end:
4) Keep X characters from the beginning:
Currently used code - with dynamic user input:
(Copy and Use at own risk!)
1) Delete X characters from the end:
Code: Select all
$nrOfChrs = input("Number of characters to delete from end:",,,,"cancel");
if (($nrOfChrs + 0) > 0) {
rename r, "^(.*)(.{" . $nrOfChrs . "})(\.[^.]+)$|^([^.]+)([^.]{" . $nrOfChrs . "})$ > $1$3$4", p, , 65;
}
Code: Select all
$nrOfChrs = input("Number of characters to delete from end:",,,,"cancel");
if (($nrOfChrs + 0) > 0) {
rename r, "^(.{" . $nrOfChrs . "})(.*)(\.[^.]+)$|^([^.]{" . $nrOfChrs . "})([^.]+)$ > $2$3$5", p, , 65;
}
Code: Select all
$nrOfChrs = input("Number of characters to delete from end:",,,,"cancel");
if (($nrOfChrs + 0) > 0) {
rename r, "^(.*)(.{" . $nrOfChrs . "})(\.[^.]+)$|^([^.]*)([^.]{" . $nrOfChrs . "})$ > $2$3$5", p, , 65;
}
Code: Select all
$nrOfChrs = input("Number of characters to delete from end:",,,,"cancel");
if (($nrOfChrs + 0) > 0) {
rename r, "^(.{" . $nrOfChrs . "})(.*)(\.[^.]+)$|^([^.]{" . $nrOfChrs . "})([^.]*)$ > $1$3$4", p, , 65;
}
[AHK] redirecting Windows Explorer to XY, [XYS] Mini Tree with open tabs (cur loc expanded, tab folders highlighted), [AHK] customInlineRenameKeys, [AHK] clipboardHelper_and_XYEscToList