Select files with same name pattern as selected
-
- Posts: 91
- Joined: 19 Mar 2008 18:15
Select files with same name pattern as selected
I have a secret to share with you guys.
Sometimes I have many files with the same name pattern, most often parts of an archive like:
chubbymaid.part1.rar
chubbymaid.part2.rar
...
chubbymaid.part497.rar
(yeah, big files obviously)
What would be cool is some right-click menu when part1 is selected so as to select all the other parts of the gorgeous, lovely archive.
I know I could go with visual filters and likes, but there are times when you shouldn't make a lady wait.
Thank you for your kind attention.
Sometimes I have many files with the same name pattern, most often parts of an archive like:
chubbymaid.part1.rar
chubbymaid.part2.rar
...
chubbymaid.part497.rar
(yeah, big files obviously)
What would be cool is some right-click menu when part1 is selected so as to select all the other parts of the gorgeous, lovely archive.
I know I could go with visual filters and likes, but there are times when you shouldn't make a lady wait.
Thank you for your kind attention.
Re: Select files with same name pattern as selected
Make a simple script and a user command / toolbar button / catalog entry?
Hints:
folderreport() to give you the list of all files with ".part" in it.
delete selection.
Done.
Hints:
folderreport() to give you the list of all files with ".part" in it.
delete selection.
Done.
One of my scripts helped you out? Please donate via Paypal
-
- Posts: 91
- Joined: 19 Mar 2008 18:15
Re: Select files with same name pattern as selected
Looks like a solution, but scripting is a daunting task for a humble lvl2 apprentice like me.
And I have often have many unrelated files with 'part' in it, dunno if it would be an issue.
And I have often have many unrelated files with 'part' in it, dunno if it would be an issue.
Re: Select files with same name pattern as selected
Hi Reve,
i think CTRL+M or CTRL+J is the way to go.
Or like highend suggested use an script like this below
to help you preparing the wanted pattern, because the
selected file name is already in the dialog for you to modify:
i think CTRL+M or CTRL+J is the way to go.
Or like highend suggested use an script like this below
to help you preparing the wanted pattern, because the
selected file name is already in the dialog for you to modify:
Code: Select all
$f = input( "Modify and leave wanted parts of file name only<crlf>
to select all other files with same part too. <crlf>
Tip: use empty filter to disable filter again", "<curname>", "<curname>");
if ($f != ""){
//filter for user pattern, (show matching files only):
filter "*$f*";
//select all (visible/filtered) files:
sel "a";
//disable filter to show all files again (selected and un-selected):
filter;
}
else{
//deselect all:
sel;
}
-
- Posts: 91
- Joined: 19 Mar 2008 18:15
Re: Select files with same name pattern as selected
Thank you, I somehow managed to save your script and create a catalog entry for it. Appreciate it.
You seem fluent in XY scripting, so do you know if it is possible to automatically discard the final /\n+\.rar/ from the filename?
So that running the script with 'chubbymaid.part1.rar' selected would pop up the dialog already filled with 'chubbymaid.part'
You seem fluent in XY scripting, so do you know if it is possible to automatically discard the final /\n+\.rar/ from the filename?
So that running the script with 'chubbymaid.part1.rar' selected would pop up the dialog already filled with 'chubbymaid.part'
Re: Select files with same name pattern as selected
Replace this:
with:
Code: Select all
$f = input( "Modify and leave wanted parts of file name only<crlf>
to select all other files with same part too. <crlf>
Tip: use empty filter to disable filter again", "<curname>", "<curname>");
Code: Select all
$default = regexreplace("<curname>", "(.+)(\d\..+)", "$1");
$f = input( "Modify and leave wanted parts of file name only<crlf>
to select all other files with same part too. <crlf>
Tip: use empty filter to disable filter again", "<curname>", "$default");
One of my scripts helped you out? Please donate via Paypal
-
- Posts: 91
- Joined: 19 Mar 2008 18:15
Re: Select files with same name pattern as selected
Works, thank you for you help, mate.
Re: Select files with same name pattern as selected
highend wrote:Replace this:
with:
Code: Select all
$default = regexreplace("<curname>", "(.+)(\d\..+)", "$1");
'(.+)' is greedy and will match as many as can get, even digits.
And '\d' will match only one single digit (the last one)
This would resulting in
"chubbymaid.part49"
for
"chubbymaid.part497.rar"
Better would be '(.+?)\d*'
where '(.+)' will stop at first found digit due the '?' modifier
and '\d*' will match none-or-more digits, and
so match even 'part' without any digit. (if wanted. If not, use '\d+' instead as ==> '(.+?)\d+')
- - -
Reve_Etrange wrote: if it is possible to automatically discard the final /\n+\.rar/ from the filename?
So that running the script with 'chubbymaid.part1.rar' selected
would pop up the dialog already filled with 'chubbymaid.part'
Code: Select all
$f = input( "Modify and leave wanted parts of file name only<crlf>
to select all other files with same part too. <crlf>
Tip: use empty filter to disable filter again", "<curname>",
regexreplace("<curbase>", "(.+?)\d*", "$1"));
if ($f != ""){
//filter for user pattern, (show matching files only):
filter "*$f*";
//select all (visible/filtered) files:
sel "a";
//disable filter to show all files again (selected and un-selected):
filter;
}
else{
//deselect all:
sel;
}
Re: Select files with same name pattern as selected
Your corrections are right Stefan,
but why should somebody ever select "chubbymaid.part49" to extract a .rar archive (although this is possible) instead of using one of the first 9 files?
But user opinions about file selection / management / tend to differ I suppose xD
but why should somebody ever select "chubbymaid.part49" to extract a .rar archive (although this is possible) instead of using one of the first 9 files?
But user opinions about file selection / management / tend to differ I suppose xD
One of my scripts helped you out? Please donate via Paypal
-
- Posts: 91
- Joined: 19 Mar 2008 18:15
Re: Select files with same name pattern as selected
Fixed the regexp on my own - I didn't want to nitpick when I had just been given a hand.
For what it's worth I'm happy with /(.+part)\d+\.rar$/
Your suggestion, Stefan, might stumble on something like 'kinkynurse4all.part99.rar' (haven't tested though).
For what it's worth I'm happy with /(.+part)\d+\.rar$/
Your suggestion, Stefan, might stumble on something like 'kinkynurse4all.part99.rar' (haven't tested though).
Re: Select files with same name pattern as selected
Btw, you don't have to use the $ for the end of line (the regex will stop on linebreaks automatically).
One of my scripts helped you out? Please donate via Paypal
-
- Posts: 91
- Joined: 19 Mar 2008 18:15
Re: Select files with same name pattern as selected
Might as well anchor it to the end, in case someone come up with some monsters like 'tear.me.apart1337.rar.part427.rar'
As rhetorical as it gets, but well - doesn't hurt.
As rhetorical as it gets, but well - doesn't hurt.
-
- Posts: 91
- Joined: 19 Mar 2008 18:15
Re: Select files with same name pattern as selected
I eventually discarded the dialog since I always accept the default choice, but there's still a small annoyance: the listview loses focus and autoscroll so as to put the selection on top.
Are there some commands to fix that?
Are there some commands to fix that?
Re: Select files with same name pattern as selected
Sorry, didn't understand the explanation.
Mind to post a screenshot and mark what's wrong?
Mind to post a screenshot and mark what's wrong?
One of my scripts helped you out? Please donate via Paypal
-
- Posts: 91
- Joined: 19 Mar 2008 18:15
Re: Select files with same name pattern as selected
I created a '::load "myfile.xys"' entry in the catalog and I click on it to run the script. Unfortunately, the catalog keeps the focus after I click on it eg. if I press 'delete', it asks for the deletion of the catalog entry, not the selected files.
In addition, if I can see that in the list (selection in blue):
In addition, if I can see that in the list (selection in blue):
and click the catalog entry running the script, I end up seeing:Folder1
Folder2
blonde
brunette
redhead.part1.rar
redhead.part2.rar
redhead.part3.rar
milf
...
i.e. the list scrolled so that the selected files are now on top, and I must move the scrollbar up so as to see the folders and files above.redhead.part1.rar
redhead.part2.rar
redhead.part1.rar
milf
...