File Naming & Conflict Strategies

File Naming & Conflict Strategies #

SaveAny-Bot lets you customize how saved files are named and how collisions with existing files are resolved, directly in Telegram via the /config and /fnametmpl commands.

/config — User Configuration #

The /config command opens an inline menu where you can change two per-user settings:

  • Filename strategy — how the saved file is named
  • Duplicate file strategy — what happens when a file with the same name already exists in the target storage

Settings are stored per user and apply to all of that user’s subsequent save/transfer tasks.

Filename strategy #

OptionBehavior
DefaultUse the original media filename, or a generated name when no original filename is available
Gen From Msg FirstGenerate the filename from the message content (e.g. caption, text) and prefer that over the original filename
TemplateRender the filename from a custom template you define with /fnametmpl

Duplicate file strategy #

OptionBehavior
Always rename (default)Keep the existing file and save the new one with an alternate name
Ask every timePrompt you with inline buttons each time a collision occurs
Always overwriteReplace the existing file with the new one
Always skipDo nothing for conflicting files
The conflict strategy only kicks in for storage backends that can detect the existence of a file. Backends that do not support existence checks will fall back to overwriting.

/fnametmpl — Custom Filename Template #

When the filename strategy is set to Template, SaveAny-Bot renders each saved file’s name using the template configured via /fnametmpl.

/fnametmpl [template]
  • Running /fnametmpl without arguments shows your current template and the help text.
  • Running it with a template string sets that template as your filename template.

The template uses Go text/template syntax. The available variables are:

VariableDescription
{{.msgid}}Telegram message ID
{{.msgtags}}Hashtags found in the message, joined with _
{{.msggen}}Filename generated from the message
{{.msgdate}}Message date, formatted YYYY-MM-DD_HH-MM-SS
{{.msgraw}}Raw, unprocessed message text
{{.origname}}The media’s original filename (if any)
{{.chatid}}Chat ID of the message

Examples:

# Fixed prefix + message id + date
/fnametmpl Image_{{.msgid}}_{{.msgdate}}.jpg

# Use original name if available, otherwise a generated name
/fnametmpl {{.origname}}
The template only takes effect when the filename strategy is set to `Template`. If template parsing fails, SaveAny-Bot falls back to the default filename naming logic.