I have some files that were converted to new files, whose name is in "orignal file name_h265" format and the extension are converted to mp4, e.g.
1.ts -> 1_h265.mp4
3.mp4 -> 3_h265.mp4
The files list look like this:
1 2.ts
1 2_h265.mp4
2.mp4
3.mp4
3_h265.mp4
4.MP4
I want to select these files:
1 2.ts
1 2_h265.mp4
3.mp4
3_h265.mp4
How to select such files?
Moderators: Hacker, petermad, Stefan2, white
Re: How to select such files?
I'm afraid that currently there is no way to make such selection with TC only.
It would be perhaps nice to be able to select files using two regex expressions where first one defines matching group of characters and second one uses it, e.g. <(.*)_h265\.mp4 > $1\..*, but it is just an idea and it doesn't work now.
It would be perhaps nice to be able to select files using two regex expressions where first one defines matching group of characters and second one uses it, e.g. <(.*)_h265\.mp4 > $1\..*, but it is just an idea and it doesn't work now.
Re: How to select such files?
You can use however following batch+powershell file:
Just save it as e.g. selectMedia.bat somewhere, add to TC buttonbar and don't forget to clear Start path field in button properties to make it working with current directory!
Another button you will need is with cm_LoadSelectionFromClip command.
So you have to open the folder with media files, press first button for calculating selection and putting it to clipboard and then press second button for selecting files according to the selection.
Code: Select all
@echo off
set "ARG_0=%~dpnx0"
set "ARG_1=%~dp0"
set "ARG_2=(.*)_h265.mp4"
set "ARG_3=$1.*"
powershell.exe -NoProfile "iex (([IO.File]::ReadAllText($Env:ARG_0)) -replace '^(.*\n)*?.*<::::>.*\n', '')" & goto :EOF
$sourceDir = $Env:ARG_1;
$pattern = $Env:ARG_2;
$replacement = $Env:ARG_3;
$selectedFiles = @();
foreach ($file in (ls "$sourceDir\*")) {
if ($file.Name -match $pattern) {
$selectedFiles += $file.Name;
$selectedFiles += $file.Name -replace $pattern, $replacement;
}
}
if ($selectedFiles) {
'Selection:';
$selectedFiles;
Add-Type -AssemblyName 'System.Windows.Forms';
[System.Windows.Forms.Clipboard]::SetText($selectedFiles -join "`n");
}
else {
'No files found';
}
Another button you will need is with cm_LoadSelectionFromClip command.
So you have to open the folder with media files, press first button for calculating selection and putting it to clipboard and then press second button for selecting files according to the selection.
-
- Junior Member
- Posts: 6
- Joined: 2021-09-01, 01:52 UTC
Re: How to select such files?
Thank you for the solution.
Finally I use TC + text editor to do it.
Filter file names by "_h265", copy the name to text editor, delete "_h265" and add "* and *" at the start and end of the file name, e.g.
"*1 2*"
then select files using this pattern
Finally I use TC + text editor to do it.
Filter file names by "_h265", copy the name to text editor, delete "_h265" and add "* and *" at the start and end of the file name, e.g.
"*1 2*"
then select files using this pattern
Re: How to select such files?
For single-time case text editor may be useful, yes. But such a script may help if you need to do such selection often or with different rules. 
