You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Name templates currently have a rather limited functionality set. Following is a list of functions I personally believed to be useful:
Truncate, where STRING longer than LEN will be truncated. This allows more rich, longer templates to be used without worrying OS filename character limit.
SafeString, where unsafe characters (invalid filename characters) will be removed/replaced from STRING. The guide's example using Replace works, but is a bit too long and is prone to accidental breakage (mistype, accidental character delete, etc.).
Extension and Stem, where STRING will be parsed as a filename and the extension/non-extension part of the string will be returned.
Pad, where NUMBER will be padded to LEN digits (e.g. {{ Pad 1 3 }} will return a string 001)
Background
I'm using tdl in a script to automatically backup my chat. The core logic of the script now looks something like this:
Which is fairly long and isn't very elegant. I also have to download one file at a time because the whole batch will fail even if only one file is having a long name, and I want most of the file to have a descriptive name instead of plain DialogID_MessageID.
Workarounds
I've made a small patch to add Truncate() and Pad() function because I need it desperately:
SafeString function is nice-to-have, but I think people should live OK without it :)
A possible solution to implement Truncate outside tdl using pure shell code is to write a jq spaghetti code to find all media with longer-than-legal filenames. It's going to be a bit fragile and really complicated though. Please paste the code below if anyone have the dare to write it.
The text was updated successfully, but these errors were encountered:
Proposal
Name templates currently have a rather limited functionality set. Following is a list of functions I personally believed to be useful:
Truncate
, whereSTRING
longer thanLEN
will be truncated. This allows more rich, longer templates to be used without worrying OS filename character limit.SafeString
, where unsafe characters (invalid filename characters) will be removed/replaced fromSTRING
. The guide's example usingReplace
works, but is a bit too long and is prone to accidental breakage (mistype, accidental character delete, etc.).Extension
andStem
, whereSTRING
will be parsed as a filename and the extension/non-extension part of the string will be returned.Pad
, whereNUMBER
will be padded toLEN
digits (e.g.{{ Pad 1 3 }}
will return a string001
)Background
I'm using
tdl
in a script to automatically backup my chat. The core logic of the script now looks something like this:Which is fairly long and isn't very elegant. I also have to download one file at a time because the whole batch will fail even if only one file is having a long name, and I want most of the file to have a descriptive name instead of plain
DialogID_MessageID
.Workarounds
I've made a small patch to add
Truncate()
andPad()
function because I need it desperately:SafeString
function is nice-to-have, but I think people should live OK without it :)A possible solution to implement
Truncate
outsidetdl
using pure shell code is to write ajq
spaghetti code to find all media with longer-than-legal filenames. It's going to be a bit fragile and really complicated though. Please paste the code below if anyone have the dare to write it.The text was updated successfully, but these errors were encountered: