#1 2010-06-26 10:38

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Consult only parts shorter then [ 10] chars as extension

Fork from that thread (http://www.den4b.com/forum/viewtopic.php?pid=4748#p4748)


Denis, Please read this only after your vacation!




eR@SeR wrote:

Added rule:
1) Extension: Detect using binary signature

Example:

Timbaland Ft. Keri Hilson, Michael Jackson & Willy William - The Way I Are (Michael Jackson Tribute)

becomes

Timbaland Ft.mp3

should be

Timbaland Ft. Keri Hilson, Michael Jackson & Willy William - The Way I Are (Michael Jackson Tribute).mp3

den4b wrote:

Everything that follows the last dot in the filename is considered to be an extension. There is no way of knowing that some random text like in your example is not an extension.

IDEA:
Couldn't you add an option to check how many chars the "extension" has
and don't accept ext longer then n chars?

If  (Len(ext)>n) Then
      NoExtension
End If


Let the user set this option somewhere so he can decide for every renaming session what is an ext and what not.

Option:
Consult only parts after the last dot shorter then [ 10] chars as extension


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

#2 2010-06-26 17:30

SafetyCar
Senior Member
Registered: 2008-04-28
Posts: 446
Website

Re: Consult only parts shorter then [ 10] chars as extension

Maybe this helps... I'm very used to get the extensions with the RegEx: \.[0-9A-Z]{1,4}$
It works very well for me...

Last edited by SafetyCar (2010-06-26 22:31)


If this software has helped you, consider getting your pro version. :)

Offline

#3 2010-06-27 18:05

eR@SeR
Senior Member
From: Земун, Србија
Registered: 2008-01-23
Posts: 353

Re: Consult only parts shorter then [ 10] chars as extension

Stefan wrote:

Couldn't you add an option to check how many chars the "extension" has
and don't accept ext longer then n chars?

Looking at Marco's defs there are many extensions having 3, less 4 chars... You can set up to 5 characters for ex. and if there is a space after last dot don't do any change (maybe not best workaround).

Let the user set this option somewhere so he can decide for every renaming session what is an ext and what not.

This could be the best solution if can fit there.

SafetyCar wrote:

Maybe this helps... I'm very used to get the extensions with the RegEx: \.[0-9A-Z]{1,4}$
It works very well for me...

In which scenarios this RegEx does action? Is it used as one rule?
Result of this example is: Clash.of.the.titans.2010.srt --> Clash.of.the.titans.srt
Maybe doesn't work for non existing ext in ReNamer's bin signature base...


TRUTH, FREEDOM, JUSTICE and FATHERLAND are the highest morale values which human is born, lives and dies for!

Offline

#4 2010-06-27 20:02

SafetyCar
Senior Member
Registered: 2008-04-28
Posts: 446
Website

Re: Consult only parts shorter then [ 10] chars as extension

In which scenarios this RegEx does action? Is it used as one rule?
Result of this example is: Clash.of.the.titans.2010.srt --> Clash.of.the.titans.srt
Maybe doesn't work for non existing ext in ReNamer's bin signature base...

The RegEx is suposed to find the current extension, (but it won't work very well if you have the skip extension activated  tongue)
Then when the extension is removed you can append the auto-detected ext.

Last edited by SafetyCar (2010-06-27 20:13)


If this software has helped you, consider getting your pro version. :)

Offline

#5 2010-06-28 13:57

SafetyCar
Senior Member
Registered: 2008-04-28
Posts: 446
Website

Re: Consult only parts shorter then [ 10] chars as extension

Damn, I found an exception, *.torrent  roll  mad


If this software has helped you, consider getting your pro version. :)

Offline

#6 2010-06-28 15:42

SafetyCar
Senior Member
Registered: 2008-04-28
Posts: 446
Website

Re: Consult only parts shorter then [ 10] chars as extension

eR@SeR wrote:

Maybe doesn't work for non existing ext in ReNamer's bin signature base...

you left me thinking about one posibility... replacing only the known extensions (known by renamer, I mean). And if it doen't find a known extension, append the new one...

Last edited by SafetyCar (2010-06-28 15:48)


If this software has helped you, consider getting your pro version. :)

Offline

#7 2010-07-15 23:46

eR@SeR
Senior Member
From: Земун, Србија
Registered: 2008-01-23
Posts: 353

Re: Consult only parts shorter then [ 10] chars as extension

Then when the extension is removed you can append the auto-detected ext.

...Or you can use that way but you have 1 step surplus using RegEx.

you left me thinking about one posibility... replacing only the known extensions (known by renamer, I mean). And if it doen't find a known extension, append the new one...

Hm hmm not sure what you meant by this? "Dubs" replace any ext if match its bin. sign. base.


TRUTH, FREEDOM, JUSTICE and FATHERLAND are the highest morale values which human is born, lives and dies for!

Offline

#8 2010-07-16 05:04

SafetyCar
Senior Member
Registered: 2008-04-28
Posts: 446
Website

Re: Consult only parts shorter then [ 10] chars as extension

eR@SeR wrote:

you left me thinking about one posibility... replacing only the known extensions (known by renamer, I mean). And if it doen't find a known extension, append the new one...

Hm hmm not sure what you meant by this? "Dubs" replace any ext if match its bin. sign. base.

My english fails here I didn't underand the last part but let me give some examples for files with bad extension (not append, and yes auto-detect):


Now this happens:

Before: Media Player.Classic
After: Media Player.lnk

Everything after the last dot is considered a extension an replaced with the good extension


And if it would only delete the known extension this would happen:

Before: Media Player.Classic
After: Media Player.Classic.lnk

As "classic" is not a extension known by renamer, it would leave it, and append the good one after

And of course the same for Stefan's first example...



In fact I think it's a good idea for safety reasons, because, for example, a "text.docx" is now renamed into "text.zip", and it's very interesting that if the docx extension is not recognized it's left there ("text.docx.zip")

---

about the "zip" detection maybe should be changed to "zip|docx|xlsx|pptx"

Last edited by SafetyCar (2010-07-16 05:14)


If this software has helped you, consider getting your pro version. :)

Offline

#9 2010-07-19 15:32

eR@SeR
Senior Member
From: Земун, Србија
Registered: 2008-01-23
Posts: 353

Re: Consult only parts shorter then [ 10] chars as extension

My english fails here I didn't underand the last part

"Dubs" (Detect using binary signature) replace any extension if match its binary signature base. I used abbreviated text, sorry.

You can use Google translate. It can help you a lot not only for English...

And if it would only delete the known extension this would happen:

Before: Media Player.Classic
After: Media Player.Classic.lnk

Provided example of yours appends an extension not replacing. You probably meant this... smile

As "classic" is not a extension known by renamer, it would leave it, and append the good one after

Only if you tick "Append to the original filename" yes. Without it, it will be replaced. ReNamer replaces (!?!) everything after a last dot in filename like here:

Timbaland Ft. Keri Hilson, Michael Jackson & Willy William - The Way I Are (Michael Jackson Tribute)

becomes

Timbaland Ft.mp3

Only solution that I see is Stefan's IDEA. To make ReNamer more "smarter" using filename length after last dot. Mine suggestion was 5 so your "classic" won't be touched in that scenario. And... If this happens it's easy to tick "Append to the original filename" like Denis said, and we get desired extension.

Do you have any other solution?

In fact I think it's a good idea for safety reasons, because, for example, a "text.docx" is now renamed into "text.zip", and it's very interesting that if the docx extension is not recognized it's left there ("text.docx.zip")

about the "zip" detection maybe should be changed to "zip|docx|xlsx|pptx"

I said that to Denis before... docx uses zip standards of compressing so it's ok. Rename it and you'll see all those files in it... I would not change that.

P.S. New winzip have new zipx extension, but ReNamer detects it like zip. Testing few zipx files I get this stable hex:

504B03043F0000000E00, ZIPX, ZIP Compressed Archive

Maybe it could be added without conflicting to zip extension which have this hex:

504B0304, ZIP, ZIP Compressed Archive

TRUTH, FREEDOM, JUSTICE and FATHERLAND are the highest morale values which human is born, lives and dies for!

Offline

#10 2010-07-19 21:58

SafetyCar
Senior Member
Registered: 2008-04-28
Posts: 446
Website

Re: Consult only parts shorter then [ 10] chars as extension

eR@SeR wrote:

And if it would only delete the known extension this would happen:

Before: Media Player.Classic
After: Media Player.Classic.lnk

Provided example of yours appends an extension not replacing. You probably meant this... smile

As "classic" is not a extension known by renamer, it would leave it, and append the good one after

No, no, I wrote what I wanted to write but is there where you don't understand me, I'm not talking about the actual behavior of the program, I was talking about my idea of improvement.

I don't know how to explain it better...

---

EDIT: This would be behavior of my suggestion:

var
  BinExt: WideString;
  
begin
  If not WideFileExists(FilePath) then Exit;

  BinExt := CalculateMetaTag(FilePath, 'BinarySign_Extension');
  
  If (BinExt<>'') then
  begin
    FileName := ReplaceRegEx(FileName, '\.(KEY|REG|AVC|MAC|MKV|SAV|LNK|CCD|ACCDB|MDB|MDS|DB|CDA|AVI|RMI|WAV|PNG|EXE|WMA|WMV|ASF|OGG|WRI|RES|WK1|PSD|SIS|BAG|ANI|M3U8|PF|MID|INF|TORRENT|JAR|VMG|PLS|RM|GZ|M3U|DOC|PPT|XLS|REG|EVT|CAB|MOV|SYS|PDF|RAR|MPG|REG|7Z|QDF|WMF|WMF|JAR|VCF|RA|RTF|MPG|AIFF|ISZ|KEY|MPC|LNG|DCU|ICO|EMF|DBX|GIF|TIF|TIF|CUR|EPS|HLP|CAB|ZIP|PWL|RPM|SYS|WPD|FLV|MPG|SWF|SWF|JPG|GZ|Z|MP3|MP3|MP3|EXE|COM|DLL|SYS|BMP|SKR|PKR)$', '', False, False);
    FileName := FileName + '.' + BinExt;
  end;
end.

But maybe denis prefers this:

var
  BinExt: WideString;
  
begin
  If not WideFileExists(FilePath) then Exit;

  BinExt := CalculateMetaTag(FilePath, 'BinarySign_Extension');
  
  If (BinExt<>'') then
  begin
    FileName := ReplaceRegEx(FileName, '\.[0-9A-Z]+$', '', False, False);
    FileName := FileName + '.' + BinExt;
  end;
end.

Last edited by SafetyCar (2010-07-19 22:38)


If this software has helped you, consider getting your pro version. :)

Offline

Board footer

Powered by FluxBB