You are not logged in.
I am trying to list the number of dashes in each line of ebooks. The reason is that the format for the ebooks should NOT contain dashes where it doesn't belong.
This is the first correct format: Author - [Series Series #] - Book Title
EXAMPLE: Tom Mix - [Strangers in the Night 01] - Roy Rogers In Texas Count of dashes should always be 2
ERROR to be corrected by me: Tom Mix - [Strangers- in the Night 01] - Roy Rogers In Texas Count of dashes is wrong at 3.
=================================
This is the 2nd correct format: Author - Book Title
EXAMPLE: Tom Mix - Roy Rogers In Texas Count of dashes should always be 1
ERROR to be corrected by me: Tom Mix - Roy-Rogers In Texas Count of dashes is wrong at 2
There are other errors in this setup but I will be able to catch them before submitting them to the "count" expression.
I am trying to catch the potential errors before importing them into Calibre and have to correct the errors there.
Is there an expression that would provide me a line by line count of the number of dashes before I import them into Calibre.
Thank you in advance for your help.
Offline
Hi Ptaker,
what would be the use for you, even if you could get and sort the NewName column like this? :
1 - Tom Mix - Roy Rogers In Texas
2 - Tom Mix - [Strangers in the Night 01] - Roy Rogers In Texas
2 - Tom Mix - Roy-Rogers In Texas
3 - Tom Mix - [Strangers- in the Night 01] - Roy Rogers In Texas
Would that really help? You would still have to inspect each file name on its own.
To let an program do the work for you, you would first have to tell
that program HOW it can detect wrongly placed hyphens (f.ex.: never between [...] )
?
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
Considering that you have two correct formats, as you stated:
1) Author - [Series Series #] - Book Title
2) Author - Book Title
You could check that every filename matches one of these patterns using a combination of Pascal Script and Regular Expressions rules. Filenames which did not match any of these patterns could get marked / highlighted to aid the manual fixing process.
If that sounds fine, we can help you with producing the right renaming rules if you are stuck.
Offline
I would greatly appreciate any help you could provide BUT I am not experienced in using or entering the Pascal Script and can only enter the regular expression rules that have been presented for other posters as well as in answer to my posts.
Your suggestion to mark / highlight is just what I need. Then with 50 or so books to go through to find the extra dashes, this would be a big help.
Offline
Here is one potential solution.
Below are two rules which will look for the desired patterns and will tag the matching files by inserting "@" sign at the front of filenames. In practice, you can insert any character at all, whatever helps you identify those files.
1) Regular Expressions: Replace expression "\A[^-]+\s-\s[^-]+\Z" with "@$0"
2) Regular Expressions: Replace expression "\A[^-]+\s-\s\[[^-]+\]\s-\s[^-]+\Z" with "@$0"
All matching files will now begin with a "@" sign. You can then use the file table context menu to "mark only changed" and then "invert marking". Only those files which didn't match your patterns will remain marked.
There any many other ways in which you can do this, but it very much depends what works best for you personally.
Offline
Okay, I am getting closer to understanding what you are proposing. Let me proceed step by step because I am losing something in the translation.
1- I set up two separate rules as you indicated.
2- I drag all the fifty files into ReNamer with the two rules checked.
3- The program indicates all the GOOD files that require no modification with a "@" at the front of the file name.
4- I hit the rename green box to proceed with renaming those GOOD files.
5- I now correct any files that do NOT have a "@" at the front of the file name.
6- Then I drag all the modified files back into ReNamer and hit the green box to rename the files if all is correct.
7- If all the files now have a "@" at the front, I drag all fifty files back in to the ReNamer and DO WHAT to remove the "@" from all of them?
Would it not be easier to just only rename those files that do NOT match the correct number of dashes in the format?
This is where I get confused. I probably need more details on your recommended procedure.
Yes I did see the file option on the bottom left that lets me choose Mark Only Changed including or excluding the case" and also saw the file "invert", that reverses the boxes selected.
Thanks for your help.
Last edited by Ptaker (2020-08-07 01:36)
Offline
How about this way:
- add the both rules
- use Preview (not rename)
- sort NewName by clicking the header to get all @ together
- go to the bad files without the @-marker
- on each bad file press F2-key to start inplace renaming
- you're done (do not press rename, just close ReNamer)
- - -
If you already had renamed, use now the Remove rule to remove the @ symbol with option Occurrences "First", perhaps more than once?
https://www.den4b.com/wiki/ReNamer:Rules:Remove
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
Stefan, thank you for the additional information and a different approach to the problem.
I did follow your steps up to and including pressing the F2 to start in place renaming. Then, it seems I am NOT done. If I close ReNamer without pressing rename, the modified files are not modified. If I press rename, the modified files do not get the "@" but the other files gets two "@" prefixes.
Second question: After I modify the bad files, what if I do not get all the "-" corrections. I should be able to get ReNamer to re-analyze the files while it is still in the preview mode and see if they too get a "@" prefix. How do I do that? My aim is to get all the modified files to have the "@" prefix. Then I know I just have to remove the prefix(es) and I am done.
Boy this seems to get to be a bigger problem than I thought. My original vision was to put 50 files into Renamer and have a count of the number of dashes. Anything over either one or two would have to be looked at depending on whether the files had two or three part sections.
Looking forward to your additional instructions.
Offline
1. I did not understood, as I think F2 works on the fly and don't needs you do press [Rename]
Perhaps I should test some more....
2. Just press [Preview] again and again until you get all.
Both steps don't need you to press [Rename] as I see this, but of course you can if you want and remove the @s afterwards.
3. If you just want to get the count of dashes / hyphens, you may want to use an PascalScript rule instead of the above:
https://www.den4b.com/wiki/ReNamer:Rules:PascalScript
FROM:
Tom Mix - [Strangers in the Night 01] - Roy Rogers In Texas.txt
Tom Mix - [Strangers- in the Night 01] - Roy Rogers In Texas
Tom Mix - Roy Rogers In Texas.txt
Tom Mix - Roy-Rogers In Texas
TO:
1 #Tom Mix - Roy Rogers In Texas.txt
2 #Tom Mix - [Strangers in the Night 01] - Roy Rogers In Texas.txt
2 #Tom Mix - Roy-Rogers In Texas
3 #Tom Mix - [Strangers- in the Night 01] - Roy Rogers In Texas
USE:
var
iOrig,iClean,iDiff:Integer;
FileNameTMP:WideString;
begin
iOrig := WideLength(FileName);
FileNameTMP := WideReplaceStr(FileName,'-','');
iClean := WideLength(FileNameTMP);
iDiff := iOrig-iClean
FileName := IntToStr(iDiff) + ' #' + FileName;
end.
Again, me think you don't need to [Rename], just use [Preview] and sort NewName column, next F2-rename the wanted ones.
But you can rename and remove afterwards all leading digits till SpaceHash.
https://www.den4b.com/wiki/ReNamer:Rules:RegEx
Expression: ^\d+\s#
Replace:
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
Ptaker, if your main issue is to identify files which do not match your patterns, than the job is done. You can use the two Regular Expression rules posted earlier. I did no suggest you to rename anything at this stage, the Preview function is all you need.
Once the files are identified correctly, you can remove files which you don't need to modify (the ones that DO match your patterns) and continue with modifying the remaining files (those that do NOT match your patterns).
So the steps are roughly:
1. Set up the two Regular Expression rules.
2. Add all your files to ReNamer.
3. Apply the rules by clicking the Preview button (this is normally applied automatically unless disabled in the settings).
4. Filter out (mark/unmark/clear) filenames which you don't need to adjust.
5. Proceed with adjustments to filenames which are left in the table by setting up new renaming rules.
6. Only then you would click the Rename button.
P.S. F2 does not rename anything, it only lets you make manual changes to the new names, so you would still need to click the Rename button.
Offline