INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: search and [selective] replace  (Read 6801 times)

yannis

  • World Citizen
  • ***
  • Posts: 229
search and [selective] replace
« on: June 04, 2016, 01:20:34 pm »

I posted in Feature requests that it'd be nice to have a selective replace function. Example: Suppose I want to search 1000 files for a certain string and replace it with another in 50 instances out of a possible 200. The function Search and Replace won't allow it, unless I handpick the 50 instances in advance. Ferday suggests that it is possible with expressions. Could someone show me how?
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: search and [selective] replace
« Reply #1 on: June 04, 2016, 06:36:20 pm »

How would you determine which files get their fields replaced, and which one's don't?

Brian.
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: search and [selective] replace
« Reply #2 on: June 04, 2016, 06:38:01 pm »

If you trigger on a tag it could work depending on what you want.  You'd have to have the tags in order thouvb
Logged

yannis

  • World Citizen
  • ***
  • Posts: 229
Re: search and [selective] replace
« Reply #3 on: June 05, 2016, 02:34:52 am »

If I preselect only the files I need changed, there's of course no reason for a selective replace. But almost every other program that I know of with a S&R function also allows selecting a large random chunk of text or whatever and inspecting each instance of a string in order to approve or skip the change. I really wonder why this seems to sound exotic.

Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: search and [selective] replace
« Reply #4 on: June 05, 2016, 07:31:12 am »

You sound like you know exactly what you want.  But reading what you've written, I have no idea what you are talking about.  The feature is something I've never seen before.  ...and the idea of using that feature has never occurred to me before.

I can try to help you, but only if I understand what you are trying to do.  Sorry you're frustrated with the responses you've gotten so far.  I just don't understand what you're asking for, or why.

Brian.
Logged

yannis

  • World Citizen
  • ***
  • Posts: 229
Re: search and [selective] replace
« Reply #5 on: June 05, 2016, 07:54:22 am »

Ok, let's take Notepad. I can open a file and select S&R to change "A" to "a". Notepad offer Replace All as does MC. But it also offers Find Next, to omit the currently selected instance and skip to the next; there I can select Replace, and skip to the next, or Find Next, and skip to the next without replacing. This is what I meant.
Logged

dtc

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3119
Re: search and [selective] replace
« Reply #6 on: June 05, 2016, 08:00:43 am »

You sound like you know exactly what you want.  But reading what you've written, I have no idea what you are talking about.  The feature is something I've never seen before.  ...and the idea of using that feature has never occurred to me before.

I can try to help you, but only if I understand what you are trying to do.  Sorry you're frustrated with the responses you've gotten so far.  I just don't understand what you're asking for, or why.

Brian.

It sounds like he wants a search and replace that asks the user if he wants to do each replace or not. There is usually 3 options - Replace, Skip, Replace All. It is useful so the replace does not make unintended changes automatically.  The program has to get a response from the user before making each change. The find and replace option in Excel does a version of this. You also see this type of option when copying files from one place to another when the copy would replace an existing file. It is a pretty common functionality. At least that is what I think he is asking for.
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: search and [selective] replace
« Reply #7 on: June 05, 2016, 08:28:18 am »

Ok, I understand the mechanics of what you want now.  Thanks.  As far as I know, this function is not present in MC and can't be emulated in any way.  It would need to be added as a feature.

So the obvious question is:  What utility does this provide?  It seems like a very brute force tool.  It might be appropriate in some circumstances.  Or it might be a waste of time.  What are you trying to do?  Can you give an example of where this would be helpful?  If it's something others could use, it seems like a simple change to make to the interface.  Just a check box like "prompt for replacement in each file", or something like that.

Brian.
Logged

yannis

  • World Citizen
  • ***
  • Posts: 229
Re: search and [selective] replace
« Reply #8 on: June 05, 2016, 09:09:38 am »

As I see it, the brute force tool is the current, non selective method.

Suppose I want to replace the Year 1971 to 1972 or change [ ; ] to [ & ] or, even harder, to replace a string inside film descriptions - the uses are infinite for me, because I've learned to work with this tool in pretty much any software I use. Right now in MC I have to preselect the files to which I want this change made, but in many cases it's much faster to do it on the fly.

Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: search and [selective] replace
« Reply #9 on: June 05, 2016, 09:16:27 am »

All of your examples can be done with expressions.  I won't do them all, but let's do the year example:

1.  Highlight all possible candidate files.
2.  Open the tagging window (Edit > Tag) and find the Year field.
3.  In the year field cut and paste:
=replace([Year],1971,1972)

You could use this same technique with each of your examples.  But I don't think you're necessarily interested in learning a new way.  So I won't argue with you.

Perhaps post your request in the "Too Easy" thread.  If it's easy to add, perhaps they will.

Brian.
Logged

yannis

  • World Citizen
  • ***
  • Posts: 229
Re: search and [selective] replace
« Reply #10 on: June 05, 2016, 09:46:53 am »

I don't mind learning new tricks, but this way is neither faster nor easier. For the hell of it I tried what you suggest; the result is again a blanket operation, all files selected were replaced.

Unless you meant that I had to handpick only the ones that I wanted to be replaced - but this is exactly what I want to avoid in the first place.

Besides, as I said, I can't think of any other app that doesn't offer this functionality.



Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: search and [selective] replace
« Reply #11 on: June 05, 2016, 09:56:54 am »

I don't mind learning new tricks, but this way is neither faster nor easier. For the hell of it I tried what you suggest; the result is again a blanket operation, all files selected were replaced.

Unless you meant that I had to handpick only the ones that I wanted to be replaced - but this is exactly what I want to avoid in the first place.

Wait, what?  You said you wanted to change 1971 to 1972.  My expression does that.  If the year is anything else, it's untouched.  Are you saying there is some other criteria that you're not specifying?  This is where I don't understand what you're trying to do.  I can't think of any instance I've ever seen in my library, or anyone else's where I'd need this. If I know the criteria, I can specify it in some way other than "I just have to see it".

But as I said before, I won't try to convince you any more.  You obviously like this idea and that's fine.

Brian.
Logged

yannis

  • World Citizen
  • ***
  • Posts: 229
Re: search and [selective] replace
« Reply #12 on: June 05, 2016, 10:14:56 am »

Yes it changes 1971 to 1972 in ALL instances I've selected. The same as in the default function in MC.

It's not a matter of convincing. I want to select my whole library and change the Year 1971 to 1972 in only 12 instances. The solution you offered just doesn't do it.
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: search and [selective] replace
« Reply #13 on: June 05, 2016, 10:19:45 am »

Oh wow, this is a little more in depth than I had thought.  It can't be done right now

I'm unsure I'd use it much but it could be handy
Logged

yannis

  • World Citizen
  • ***
  • Posts: 229
Re: search and [selective] replace
« Reply #14 on: June 05, 2016, 10:26:52 am »

I had proposed this feature back in MC 18; it isn't implemented since then, even though it's offered by any software in the market.
Logged

fitbrit

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4887
Re: search and [selective] replace
« Reply #15 on: June 05, 2016, 10:51:10 am »

For anyone who still doesn't get it, this would be more like a word processor's find and replace option, where each instance of the find text can be highlighted and inspected before deciding to change it or not. This would be a very useful option for tagging in MC, especially when there are errors made that cannot be fixed in bulk without screwing up a large number of tags.

Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: search and [selective] replace
« Reply #16 on: June 08, 2016, 06:26:48 pm »

Let me have a go at this one.

First, the Find & Replace in Word works because it finds each instance and shows it in context, in place in a document. So it is easy to decide if each instance should be replaced or not. What you are doing when you decide to replace or not is applying additional criteria to the selection process. You may not exactly know what that criteria is when you start the search, but when you see the result found in context, you can apply the additional criteria and make a decision to change that instance or not.

The same cannot be done in MC, because what is found will probably not be shown in context, depending on the View being used. If you were searching your whole Library, you might use the Files View. In that case all you will be able to see is the columns in your File View. You would not see all tags / metadata for a record, unless you add them all to a View, or select each result and check the Tagging window for each, before deciding to make the change or not. If you added every tag to a View you would have to select each record so the one you were reviewing was highlighted, then scroll left and right to review all tags. Or select each record and scroll up and down the tag window to review tags. This would be very time consuming, and prone to mistakes I suspect.

For example, if you wanted to replace some instances of 1972, the Find would find ALL instances. Let's assume that MC finds each instance and shows it to the user (which it doesn't at the moment, and the value found may not be visible on the View being used, so how is that going to work, and keep the Find & Replace active). The first instance is in the [Year] field, which is visible in your View. In your mind, how do you decide to replace this value or not? Would it depend on the Album, Artist, Genre, part of the file path, or something else? In most cases you will need to see ALL of the data associated with the record in which 1972 has been found, in order to decide if there is a criteria, currently undefined, that would apply to this record and hence it should be changed. How would you do that in MC? Could you do that efficiently?

Maybe if you had created a custom popup with all data for the records you could hover your mouse over the one found, and hence decide based on that data if the instance should be changed. Maybe if MC had a Form that could be opened for any record, without losing the underlying search result, and while keeping the Find & Replace in process. But MC doesn't have that.

The key to doing this easily is knowing the criteria that you want to apply. But if you don't, then it is recognising the criteria as you find multiple records which are a superset of the results you want.

So Yannis, you have 183,000 audio tracks in your library, but you only want to search 1,000 for "1972" (Note: I've changed your search to 1972 because that works in my database as an example. I know you are searching for 1971.  ;D) So you have already applied some search criteria, to reduce the target of your search from 183,000 to 1,000. That makes perfect sense, as we know that if you wanted to change [ & ] to [ and ] using Find & Replace, you are going to be at it for a very, very long time, evaluating each instance found.

So if you have applied one search criteria to get down to 1,000 records to search, why not continue to apply search criteria until you are down to only those records you want to change, or maybe 53 results, which you could select, and de-select the 3 you didn't want to change?

You haven't said how you decided on the 1,000 records to search, but I'm sure it was using a view, or a search of the whole library. I'm going to use my example to show how I would go about what you want.

First, I select the Files View of all my audio. 28,088 records.
Then using the search field in the top right corner I put "1972" (without the quotes of course). 72 records.
I see that all but one result has a value of 1972 in the [Year] field. The last record has 1972 in the file name. I don't want that record, so I'm going to change my search to eliminate it.
I put "year=1972" in to the search field. 71 records.
Now I can see I have a mixture of Country, Rock, Comedy, Bluegrass, Other, etc. in the Genre field. I actually know that I want to fix a bunch of Rock tracks which have mixed Dates when they shouldn't.
So I change my search to  "year=1972 genre=rock". 48 records.
Now I see I have a mixture of Artists, but the records I want to correct are all Neil Diamonds tracks.
I add Neil to my search criteria, to give "year=1972 genre=rock Neil". 22 records.
Now I can see that the problem tracks were all from "A Hot August Night", and it is Disc 1 that has the incorrect date against it.
I could add "Disc 1" to my search criteria now, to give "year=1972 genre=rock Neil "Disc 1"", but as I can see all the records I want to change...

I select the 14 tracks from Disc 1 of the 22 total tracks and change the Date to 1971 (for example).
Done.

If I was able to get down to just the records I wanted to change, but the value "1972" was in more than one tag, I could now use the existing Find & Replace in MC to correct all records at once.

Now, the above may seem long winded, but actually it can be done very quickly and it mirrors the thought process you are going through when you use Find & Replace in Word, except that you are working on all records at once, instead of reviewing one at a time. I believe that the above process would actually be much faster than using a Find & Replace function. Could you imagine doing a Find & Replace on even 1,000 records, let alone 183,000?

Read and learn this: http://wiki.jriver.com/index.php/Search_Language
Try putting "genre=& OR name=& OR artist=&" in the search field in your Files View, one criteria at a time.
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

yannis

  • World Citizen
  • ***
  • Posts: 229
Re: search and [selective] replace
« Reply #17 on: June 09, 2016, 04:25:25 am »

Hi RoderickGI,

This is certainly a very informative explanation of how MC works and your workflow is indeed helpful in many cases. But I only brought up "1971" as a general example to keep things simple, and you guys seem take it literally. Perhaps I was unintentionally misleading. So let me offer another situation, where predefining a list of candidates is not as easy.

In a real world scenario, I want to correct spelling errors, replacing "c" to "ç" (as in "Dança" or "Canção"). I can drill down to a list of only Brazilian songs, but from then on? There's no way to differentiate, so that danca becomes daa while banca stays banca. (Unless of course S&Ring all possible keywords one by one.)

I could of course retag from external sources, but that wouldn't cover custom fields. And a workaround, sometimes, is to use F3 to highlight a search term in my View, and to fill in a temp custom field, by which to create a candidates list. But again, auto replacing in a broad case such as the one above is not feasible.

Bottomline -and I'm not a coder, so please bear with me- I'd just like to understand the why of it. As a catalog freak, I've used programs of all sorts, based on SQL DBs, python, .net framework - you name it; good or bad, most of them offer in some way this functionality, even locating strings deep inside multi-line fields like a film's plot etc. So, what keeps such an amazing app as MC from being able to do it?

 
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: search and [selective] replace
« Reply #18 on: June 09, 2016, 07:40:10 pm »

Believe me, I never took your example as a literal example. It was way too simple.

When answering questions on the forum we often have to pull teeth to get people to share what their real problem is, either because they don't understand it, or can't be bothered to explain it, or they expect us to just know what they mean even if they haven't said what the problem is. Then if we ask for more information, some explanation, they get frustrated and/or angry. Or just disappear from the site never to return and provide more information. Many times our questioning embarrasses them because they realise, or think, they are asking something stupid, or have missed some obvious point.

We are not paid to respond to posts here, or put up with abuse from people. So we just use the information that we are given.

If you had provided the real world problem from the beginning, we would have made progress much faster.

My problem with your request for a Find & Replace that allows a review of each Find result is that it would take an enormous amount of time to go through all the instances of "c" found, to decide if it should be replaced with "ç". I'm sure there are many more characters that you need to review, not just "c", so my approach, and the method I described, is to eliminate the big chunks of what you don't need to check, and narrow the issue down as much as possible before doing the difficult task, checking and correcting instances of "c" that should be "ç".

So, what keeps such an amazing app as MC from being able to do it?

I have no idea why JRiver haven't done what you ask. It should be easy to do, and easy to provide an option in Find & Replace to allow for review. I suspect they haven't done it for good reason, possibly because no-one has shown a real need for it. Your first example didn't show a need. I'm not sure you current example does either, but maybe it could help in this case.

So, how would I do what you need to do?

I would create a view of just my Brazilian songs, then I would look through the result until I spotted a problem word, say "danca". I would then add a search for "danca" using the view to see how many songs had the issue. I would also look for instances where capitalisation was necessary, since "Danca" and "danca" should be treated differently then. If there were only a few instances I might just fix them. If more than a few I would use Find & Replace to fix them. If there were some capitalisation issues I would set the "Match case" flag in Find & Replace, finding "danca" once and then "Danca". Then I would clear the search and move on to the next word, such as "Cancao".

Using the above method I could progressively work through the corrections. Whenever I noticed the incorrect spelling of a word, I could open my view, search for the word, and fix all instances of that word. Spreading the work load, rather than trying to do all instances of "c" at once, or doing a whole bunch of instance of "c", only to not finish and then have to go back and find all instances of "c" and review them again later, seems like a good idea.

Now I understand that a lot of different words may need changes from "c" to "ç", so searching and replacing word by word is still a big job. But I think it would be smaller than finding all instances of "c", reviewing the word it is in, and then replacing if necessary. I could be wrong in that, but the work load couldn't be bigger using word searches, so the above is a solution with current functionality that you can use.

The real and best solution, I suspect, would be to run a Brazilian spell checker across all of MC, and have it correct these errors. But I don't know how that could be done.

I can't do anything about changing the functionality. I can only help by suggesting how you could solve an issue using existing functionality. Hopefully the above helps.
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

yannis

  • World Citizen
  • ***
  • Posts: 229
Re: search and [selective] replace
« Reply #19 on: June 09, 2016, 11:34:43 pm »

OK, I guess I'm the one who should be literal  :)   But thanks for understanding the problem.

What you describe is more or less what I've already done, but it's obviously a tedious operation that can be avoided.
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: search and [selective] replace
« Reply #20 on: June 10, 2016, 12:44:22 am »

For anyone who still doesn't get it, this would be more like a word processor's find and replace option, where each instance of the find text can be highlighted and inspected before deciding to change it or not. This would be a very useful option for tagging in MC, especially when there are errors made that cannot be fixed in bulk without screwing up a large number of tags.
I've not read all of the posts in this thread, but, this caught my eye...

You know that if you have a list of files, and you press ctrl+q to open the quick find bar at the foot of the list, and type, even just one letter in the search box there, all instances in the list are hilighted?
I'm not sure if that is relevant or helpful, but it is what happens... If you then press the "Find All" button, all those files become selected...

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: search and [selective] replace
« Reply #21 on: June 10, 2016, 02:09:40 am »

I've never found the Quick Find bar particularly useful, compared to the Search Box.

But just playing with it again, it does highlight the difficulty of using a selective Find & Replace in MC.

The found text is not always visible in the view you are using. Even if the view includes all fields, the actual text may be scrolled off to the right.
Even with the record selected, I still had to hunt around to find the criteria text, sometimes having to open the tag window, and sometimes the bottom pane. i.e. In the Album view.
If using a view that includes a summary, i.e. Album view, and the search matches a track, you have to open the bottom pane to even see the track, and still the criteria text isn't highlighted. You have to repeat the find in each pane. Basically it is a pane based find.
The criteria text isn't highlighted in the tag window, if you open the tag window to try to find the criteria text.
The "Find Next" can be quite slow to respond.
The "Find All" selects all records with matching text, but doesn't eliminate non-matching records, and doesn't group them together.

However, using the search box in a view to reduce the number of displayed records, and then using the Quick Fin bar, in both panes if required, to highlight the criteria text does help somewhat.

As an example I tried a search of the Album view with the track pane open at the bottom, and both showing details.
In the search box I put "The", and then the same in the Quick Find bar in each pane.
I could see straight away that there were a bunch of matches on the Genre "Other" and the word "Theatre", which could only be eliminate manually. So having the matching words highlighted by the Quick Find bar does help in that situation.
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

yannis

  • World Citizen
  • ***
  • Posts: 229
Re: search and [selective] replace
« Reply #22 on: June 10, 2016, 02:26:57 am »

Correct in every respect; one could of course limit the fields and work in batches to avoid having to scroll around, but that doesn't help in multi-line fields. All the more reason, then, for a focused S&R.
Logged
Pages: [1]   Go Up