Jump to content

Name pattern separator handling


majstang

Recommended Posts

Hi!

 

I wonder if there is a chance to add some nicer separator handling for name pattern eventually? The issue is if the variable is empty the separator gets applied no matter what, which looks a bit odd in the file name.

This is my name pattern:

%year%m%d_%time_%station_%event - %title

Perhaps using some ternary operators to handle it? For example the title (sub-title) after identifying which separators the user has (in an AHK sample): (title ? " - " : "") which implies if title has value the - separator gets applied with a leading and trailing space, else title is empty and the - separator gets removed together with the leading and trailing spaces.   

 

Regards

majstang

Edited by majstang
Link to comment

Quite often shows dont have a sub-title which implies this file name:

20170425_20-59-04_TV3_Världens bästa burgare -.ts

After %event the leading space and the "-" is still there. The trailing space actually seems to be removed cuz the punctuation comes directly after " -" separator. 

With some separator handling the file name would look like this:

20170425_20-59-04_TV3_Världens bästa burgare.ts

 

This handling could be applied to all name pattern variables if for some unknown reason they might be empty. 

Link to comment

Here is a code sample:

  ;20170425_20-59-04_TV3_Världens bästa burgare -.ts
  ;%year%m%d_%time_%station_%event - %title
  year := "2017"
  m := "04"
  d := "25"
  time := "20-59-04"
  station := "TV3"
  event := "Världens bästa burgare"
  title := ""
  ;title := "“Las Vegas”"
  ext := ".ts"

  string := % year . m . (d ? d "_" : "") . (time ? time "_" : "") . (station ? station "_" : "") . event . (title ? " - " title : "") . ext
  msgbox % string

Tricky part is to identify which separators the user is having in name pattern string and construct the ternary operators thereafter, but it is doable with some RegEx or SubStr()/InStr() and nifty wit to cover all possible cases :)

Edited by majstang
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...