More > JRiver Media Center 25 for Windows

Advanced Tag Editing: Remove Actors With Only One Title

<< < (3/14) > >>

zybex:
You'll need to manipulate it outside of MC, either via a script or Excel (plus SWOT to re-import the data)
A 20-line 40-line VBA function in Excel can do it, if you feel your life doesn't have enough pain already ;D

Edit: VBA works ;)


--- Code: ---Sub countUniqueActors()
    Dim name As String
    Dim Names() As String
    Dim cel As Range, all As Range
    Set d = CreateObject("Scripting.Dictionary")
    lastRow = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row + 1
   
    AllowZeroActors = False     'change to True to allow removing all actors from a movie (if they're all unique)
    ListRemovedActors = False   'change to True to write the removed actors on the next column (overwrites existing data there!)
   
    Set all = Application.Selection
    If all.Cells.count < 2 Then
        MsgBox ("Please select a range of cells")
    Else
        ' phase 1 - count each actor occurences
        For Each cel In all.Cells
            If cel.Row > lastRow Then Exit For
            If cel.Value <> "Actors" And Trim(cel.Value & vbNullString) <> vbNullString Then
                Names = Split(cel.Value, ";")
                For i = LBound(Names()) To UBound(Names())
                    name = LCase(Trim(Names(i)))
                    count = d(name)
                    d(name) = count + 1
                Next
            End If
        Next
       
        'count unique items in dictionary
        once = 0
        For Each n In d.Keys
            If d(n) = 1 Then once = once + 1
        Next
       
        'phase 2 - cleanup unique actors, except if all actors in a movie are unique
        If vbYes = MsgBox(Str(d.count) & " actors, " & Str(once) & " seen only once." & vbCrLf & vbCrLf & "Do you want to Cleanup?", vbYesNo) Then
            For Each cel In all.Cells
                If cel.Row > lastRow Then Exit For
                If cel.Value = "Actors" And ListRemovedActors Then cel.Cells(1, 2).Value = "Removed"
                If cel.Value <> "Actors" And Trim(cel.Value & vbNullString) <> vbNullString Then
                    newval = ""
                    Names = Split(cel.Value, ";")
                    removed = ""
                    For i = LBound(Names()) To UBound(Names())
                        name = LCase(Trim(Names(i)))
                        If d(name) > 1 Then
                            newval = newval & "; " & Trim(Names(i))
                        Else
                            removed = removed & "; " & Trim(Names(i))
                        End If
                    Next
                    newval = Trim(Mid(newval, 3, Len(newval)))
                    removed = Trim(Mid(removed, 3, Len(removed)))
                    If (AllowZeroActors Or newval <> "") And newval <> cel.Value Then cel.Value = newval Else removed = ""
                    If ListRemovedActors Then cel.Cells(1, 2).Value = removed
                End If
            Next
            MsgBox ("Done!")
        End If
    End If
End Sub

--- End code ---

andrewberg:
Million thanks @ zybex for all that labour... Not sure if I will go to such extremes (the VBA code looks daunting... ;-)

So how to apply the Excel function? I guess the first steps are like this:


* Group my view by actors,
* sort by number of titles,
* select the 'one file-per-actor' titles
* export the selection to an Excel file,
* ...?
By the way, there IS a major difference between the 'Artist' and 'Actor' fields; while both are the 'semicolon delimited list' type, the input type for 'Artist' is 'Standard', for 'Actor' it is 'List'... As a result (see prev. post), each file/title can have only 1 artist, but multiple actors to it!

zybex:
No need for Views or Smartlists.
- Just open any View in Details mode (or Video->Files), make sure the Actors column is visible, CTRL+A to select all, CTRL+C to copy.
- Open Excel, CTRL+V to paste. Select all cells from the Actors column (do NOT select the entire column or else the code will have to check 1 million rows! Code needs fixing to prevent that)
- ALT+F11 to open the VBA editor, double-click on This Workbook, paste the code.
- Press PLAY on the VBA Editor toolbar

That should clean up the names in the Actors column... but now you have the problem of putting it back into MC. Bulk copy/paste doesn't work from Excel to MC, so you'll have to use SWOT/Fiddler or something like that. as Wer says below, you can just paste back the column into MC.

Instructions:
https://yabb.jriver.com/interact/index.php/topic,106802.msg742297.html#msg742297

wer:

--- Quote from: zybex on March 04, 2021, 05:27:35 pm ---... but now you have the problem of putting it back into MC. Bulk copy/paste doesn't work from Excel to MC, so you'll have to use SWOT/Fiddler or something like that.

--- End quote ---

Pasting from Excel into MC works fine, but you can only paste one tag at a time.

So you'd have to select the cells (in a column) that comprise your Actors field (don't select the header row), and when you do a paste tags, check only the Actors field.

The number of cells in the clipboard must exactly match the number of files selected in MC.

andrewberg:

--- Quote from: wer on March 04, 2021, 05:51:12 pm ---So you'd have to select the cells (in a column) that comprise your Actors field (don't select the header row), and when you do a paste tags, check only the Actors field.
The number of cells in the clipboard must exactly match the number of files selected in MC.
--- End quote ---

Thanks @ wer, I might give that a shot, once I understand what you mean by "paste tags, check only the Actors field", how does that go in MC?

And by the way, the resulting Excel cells will never match the number of files I first selected in MC -- there will be thousands less once I've removed the 'one-film' actors (which was the overall idea... ;-)

Or let me know if I got anything wrong -- many thanks again for all your effort!

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version