This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Krename Find & Replace expressions

Tags: krename, replace krename, replace krename, replace
(comma "," separated)
fozziebear
Registered Member
Posts
5
Karma
0

Krename Find & Replace expressions

Mon Jun 29, 2020 11:22 am
I have several hundreds podcasts which I want to transfer to an mp3 player but the format and title of the file name is too long/complicated. Here is an example of such a file:-
The_Grenfell_Tower_Inquiry_Podcast_-_27_Firefighter_OBeirne_and_Senior_Fire_Safety_Officer_Egan_p06csh8y_podcast.mp3

I need to remove the underscores and title so that it sorts numerically and also the word podcast and the PID e.g.

27 Firefighter OBeirne and Senior Fire Safety Officer Egan.mp3

I have used the Find and Replace option of Krename but don't know what to use in the Replace With field other than a space (ie using the spacebar) but that puts unwanted spaces in the file name and occasionally wont work for strings of characters.
How do you remove characters or text and replace them with nothing?

Secondly each file has its own PID identifier that varies but is in the format p06csh8y. Is there a way of stripping these out when the characters are variable bt fit a standard format? More on the BBC Program Identifier below. https://en.wikipedia.org/wiki/BBC_Programme_Identifier#:~:text=A%20BBC%20Programme%20Identifier%20(PID,iPlayer%20viewers%2C%20and%20internal%20databases.

I am aware this issue is not limited to Krename but is a general programming/File Management routine but don't know where to ask questions as Krename doesn't appear to be developed or supported any more. If there is a specific source of information perhaps someone would be kind enough to point me in the right direction.
User avatar
Mamarok
Manager
Posts
6071
Karma
16
OS
Why not use Kid3 for this? It will do exactly what you want and you can also get the proper ID3 tags for your mp3 format.


Running Kubuntu 22.10 with Plasma 5.26.3, Frameworks 5.100.0, Qt 5.15.6, kernel 5.19.0-23 on Ryzen 5 4600H, AMD Renoir, X11
FWIW: it's always useful to state the exact Plasma version (+ distribution) when asking questions, makes it easier to help ...
fozziebear
Registered Member
Posts
5
Karma
0
Mamarok wrote:Why not use Kid3 for this? It will do exactly what you want and you can also get the proper ID3 tags for your mp3 format.

Thank you Mamarok but these are podcast files in m4a format which i'll convert to mp3 to be compatible with my mobile player. The software you have directed me to is specifically for mp3 music files and wont work with my podcast files as they dont have ID3 Tags.
I have been using Krename sucessfully for months to rename movie and other files I have downloaded but I am stuck on removing spaces and unwanted characters such as the 8 character PID. I am sure there must be a way of doing this but I am not a programmer and don't know the syntax.
Krename seems to use "Tokens" for advanced file name edits including " "\ which is supposed to remove trailing and leading spaces but I only want to remove a space before the extension.I am not sure how to even load tokens in the software.
I really need to hear from someonewho uses Krename regularly with complex file names.
Many thanks
Fozzie
visone
Registered Member
Posts
32
Karma
0
OS
Hi!
find --> any valor you want to change
replace with --> if you want a space, just press space or leave it blank por nothing
fozziebear
Registered Member
Posts
5
Karma
0
visone wrote:Hi!
find --> any valor you want to change
replace with --> if you want a space, just press space or leave it blank por nothing


Thanks Visone. I have tried this and if I put nothing in the Replace field the file remains unchanged. Also I am trying to remove spaces too.

Fozzie
visone
Registered Member
Posts
32
Karma
0
OS
Hi!
Im usually do this to erase de spaces find --> press space replace with --> .
That works for me
If you want to reduce the name, in advance filename/ template use something like this [1-15] to choose from the first to 15's characters. You can start to count from whatever you want [15-25]
User avatar
pappl
Registered Member
Posts
22
Karma
0
fozziebear wrote:I have several hundreds podcasts which I want to transfer to an mp3 player but the format and title of the file name is too long/complicated. Here is an example of such a file:-
The_Grenfell_Tower_Inquiry_Podcast_-_27_Firefighter_OBeirne_and_Senior_Fire_Safety_Officer_Egan_p06csh8y_podcast.mp3

I need to remove the underscores and title so that it sorts numerically and also the word podcast and the PID e.g.

27 Firefighter OBeirne and Senior Fire Safety Officer Egan.mp3

......


At first Krename is a great tool. I renamed thousands of photos, and it works perfectly well. Hope there will be further development, because there are no better GUI renaming tools for linux systems.
I hope Search & Replace function will be visually optimized in the future to make it easier to use.

How to rename:
1. Drag and drop all your files you want to rename the same way in the first column.
Image

2. Activate the checkbox in the bottom to overwrite files
Image

3. Skip this column if you don't need data from EXIF-files or other complicated renaming tools
Image

4. Click Search and Replace button.
Image

Click Add Button. In Search field paste the part you want to remove. Leave Replace field empty if you want to remove the charactes.
If you want to replace it with other characters then type in the new text.
Activate all checkboxes "Regular expression".

==========================================
In your case 3 steps necessary (3x add):
Search: The_Grenfell_Tower_Inquiry_Podcast_-_
Replace: leave empty

Search: _p06csh8y_podcast
Replace: leave empty

Search: _
Replace: hit spacebar once
=========================================

Look at preview, hit Rename button. Done.

Only if it does not work, then try to add this char (^) in search filed at the beginning:
Code: Select all
^The_Grenfell_Tower_Inquiry_Podcast_-_





pappl
fozziebear
Registered Member
Posts
5
Karma
0
Thank you so much for your detailed reply Pappl.
I have been meaning to come back to this forum and post my results following Visone's last post.
I think I have discovered why Find and Replace has not been working for me in some cases. I have found that in the Find box I have to put a space before the character or nothing happens. Also when I leave the Replace box empty I sometimes find I end up with multiple spaces in the file name. This has to be corrected by adding another expression with three spaces in the Find box and nothing in the replace field. This could be because I am creating too many individual expressions in Find and Replace to remove different things?

I also don't really understand the difference between the two Functions (trimmed) and (trimmed;.*.) to remove white spaces in a file name and which I should use.
The hardest part which is beyond me is removing the PID number from any media downloaded from iPlayer using get_iplayer. This is the unique programme identity number and varies for every file. In your suggestion _p06csh8y_podcast this would only replace the one entry leaving all other PIDs behind. I am sure a programmer would be able to write an expression to identify varying PIDs which nevertheless follow a standard pattern e.g. for the previous example p06csh8y LNNLLLNL where L- letter and N=number in a string of characters. I am not a programmer and would not know where to start.
Many thanks
Fozzie
rlaggren
Registered Member
Posts
1
Karma
0
> replace with nothing...
Some programs will accept "" (two double quotes, no space between) as "nothing"

> [fine-replace MD number]
IF (I'm not up on the MD numbers) the number is _always_ the same length an _always_ occurs between two "_" chars, or, even better, always occurs between "_" and the string "_podcast", then searching for any string (or maybe, if true, any string beginning with the char "p") and containing the exact (correct) number of chars, should "Find" the MD number (including the extra chars before and after which allow you to catch the correct string - in this case the "_" chars and maybe the word "podcast"). Then replace it with whatever right for you.

To do this you would need to use "Regular Expressions" by checking the box in the Find/Replace dialog. I'm a total newbie to Regex (short name for the program that operates using regular expressions), but I have something of a similar problem so have been looking at it today. Here is one of the pages I found most helpful:

https://www3.ntu.edu.sg/home/ehchua/pro ... egexe.html

There is a _lot_ of comment on Regex because it's really cryptic, but that page has the beginnings of an understandable explanation.

I _think_ the the following expression will find your MD number (including the extra chars before an after that you need to help locate the MD number). I will, from your example, take the MD number to be 8 chars long and that it is preceded and followed by "_" and "_podcast"; the idea is to find the string that begins with "_", followed by and 8 letters or numbers, and ends in "_podcast":

_[/w]{8}_podcast

Place the above in the Find field and check the Regex box.

I hope. Regex is a powerful but totally cryptic search definition language and I'm just starting to study it. So my Regex expression above could be not-quite-right... However, I have got some Regex expressions to work in krename, so it appears that the Regex feature does work. Perhaps somebody more familiar with Regex will chime in.

Regards,
Rufus
User avatar
abury
Registered Member
Posts
190
Karma
1
OS
I had similar hurdles with my audio collection...
and after much messing around, I recalled that in my Xfce days, Thunar had a renaming tool
so installed thunar and its bulk renaming tool is seriously the best!


KDE neon 5.20 - Plasma 5.20.5 - Frameworks 5.78 - Qt 5.15.2 - Kernel 5.4.0-65
fozziebear
Registered Member
Posts
5
Karma
0
rlaggren wrote: replace with nothing...
...


Many thanks Rufus. I will try your suggestions above as soon as I get time. Thank you for such a detailed response.
Fozzie


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell