Files
SaveAny-Bot/en/usage/config/index.html
2026-06-28 10:00:28 +00:00

33 lines
11 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="
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&rsquo;s subsequent save/transfer tasks."><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://sabot.unv.app/en/usage/config/"><meta property="og:site_name" content="Save Any Bot"><meta property="og:title" content="File Naming & Conflict Strategies"><meta property="og:description" content="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 users subsequent save/transfer tasks."><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="usage"><meta property="article:modified_time" content="2026-06-28T18:00:02+08:00"><title>File Naming & Conflict Strategies | Save Any Bot</title><link rel=icon href=/favicon.png><link rel=manifest href=/manifest.json><link rel=canonical href=https://sabot.unv.app/en/usage/config/><link rel=alternate hreflang=zh href=https://sabot.unv.app/usage/config/ title=文件命名与重名策略><link rel=stylesheet href=/book.min.a22f4c7d8c2bdc5e3d6e34ba11cb59ab50ea5772594e71305bfd5a595dc78b7e.css integrity="sha256-oi9MfYwr3F49bjS6EctZq1DqV3JZTnEwW/1aWV3Hi34=" crossorigin=anonymous></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/en/><img src=/logo.png alt=Logo class=book-icon><span>Save Any Bot</span></a></h2><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
<label for=languages class=flex><a role=button class="flex flex-auto"><img src=/svg/translate.svg class=book-icon alt=Languages>
English</a></label><ul><li><a href=/usage/config/>简体中文</a></li></ul></li></ul><ul><li><a href=https://github.com/krau/SaveAny-Bot target=_blank rel=noopener>🔗 GitHub</a></li></ul><ul><li><span>Deployment Guide</span><ul><li><a href=/en/deployment/configuration/>Configuration Guide</a><ul><li><a href=/en/deployment/configuration/storages/>Storage Configuration</a></li></ul></li><li><a href=/en/deployment/installation/>Installation and Updates</a></li></ul></li><li><a href=/en/usage/>Usage</a><ul><li><a href=/en/usage/silent/>Silent Mode</a></li><li><a href=/en/usage/rules/>Storage Rules</a></li><li><a href=/en/usage/watch/>Watch Chats</a></li><li><a href=/en/usage/directlinks/>Direct Download Links</a></li><li><a href=/en/usage/aria2/>Aria2 Download</a></li><li><a href=/en/usage/ytdlp/>yt-dlp Video Download</a></li><li><a href=/en/usage/transfer/>Storage Transfer</a></li><li><a href=/en/usage/parsers/>Save Files Outside Telegram</a></li><li><a href=/en/usage/config/ class=active>File Naming & Conflict Strategies</a></li><li><a href=/en/usage/api/>HTTP API</a></li><li><a href=/en/usage/cli/>CLI Subcommands</a></li></ul></li><li><a href=/en/help/>Frequently Asked Questions</a><ul></ul></li><li><a href=/en/contribute/>Contributing</a><ul></ul></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/svg/menu.svg class=book-icon alt=Menu></label><h3>File Naming & Conflict Strategies</h3><label for=toc-control><img src=/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#config--user-configuration><code>/config</code> — User Configuration</a><ul><li><a href=#filename-strategy>Filename strategy</a></li><li><a href=#duplicate-file-strategy>Duplicate file strategy</a></li></ul></li><li><a href=#fnametmpl--custom-filename-template><code>/fnametmpl</code> — Custom Filename Template</a></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=file-naming--conflict-strategies>File Naming & Conflict Strategies
<a class=anchor href=#file-naming--conflict-strategies>#</a></h1><p>SaveAny-Bot lets you customize how saved files are named and how collisions with existing files are resolved, directly in Telegram via the <code>/config</code> and <code>/fnametmpl</code> commands.</p><h2 id=config--user-configuration><code>/config</code> — User Configuration
<a class=anchor href=#config--user-configuration>#</a></h2><p>The <code>/config</code> command opens an inline menu where you can change two per-user settings:</p><ul><li><strong>Filename strategy</strong> — how the saved file is named</li><li><strong>Duplicate file strategy</strong> — what happens when a file with the same name already exists in the target storage</li></ul><p>Settings are stored per user and apply to all of that user&rsquo;s subsequent save/transfer tasks.</p><h3 id=filename-strategy>Filename strategy
<a class=anchor href=#filename-strategy>#</a></h3><table><thead><tr><th>Option</th><th>Behavior</th></tr></thead><tbody><tr><td><code>Default</code></td><td>Use the original media filename, or a generated name when no original filename is available</td></tr><tr><td><code>Gen From Msg First</code></td><td>Generate the filename from the message content (e.g. caption, text) and prefer that over the original filename</td></tr><tr><td><code>Template</code></td><td>Render the filename from a custom template you define with <code>/fnametmpl</code></td></tr></tbody></table><h3 id=duplicate-file-strategy>Duplicate file strategy
<a class=anchor href=#duplicate-file-strategy>#</a></h3><table><thead><tr><th>Option</th><th>Behavior</th></tr></thead><tbody><tr><td><code>Always rename</code> (default)</td><td>Keep the existing file and save the new one with an alternate name</td></tr><tr><td><code>Ask every time</code></td><td>Prompt you with inline buttons each time a collision occurs</td></tr><tr><td><code>Always overwrite</code></td><td>Replace the existing file with the new one</td></tr><tr><td><code>Always skip</code></td><td>Do nothing for conflicting files</td></tr></tbody></table><blockquote class="book-hint info">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.</blockquote><h2 id=fnametmpl--custom-filename-template><code>/fnametmpl</code> — Custom Filename Template
<a class=anchor href=#fnametmpl--custom-filename-template>#</a></h2><p>When the filename strategy is set to <code>Template</code>, SaveAny-Bot renders each saved file&rsquo;s name using the template configured via <code>/fnametmpl</code>.</p><pre tabindex=0><code>/fnametmpl [template]
</code></pre><ul><li>Running <code>/fnametmpl</code> without arguments shows your current template and the help text.</li><li>Running it with a template string sets that template as your filename template.</li></ul><p>The template uses Go <a href=https://pkg.go.dev/text/template><code>text/template</code></a> syntax. The available variables are:</p><table><thead><tr><th>Variable</th><th>Description</th></tr></thead><tbody><tr><td><code>{{.msgid}}</code></td><td>Telegram message ID</td></tr><tr><td><code>{{.msgtags}}</code></td><td>Hashtags found in the message, joined with <code>_</code></td></tr><tr><td><code>{{.msggen}}</code></td><td>Filename generated from the message</td></tr><tr><td><code>{{.msgdate}}</code></td><td>Message date, formatted <code>YYYY-MM-DD_HH-MM-SS</code></td></tr><tr><td><code>{{.msgraw}}</code></td><td>Raw, unprocessed message text</td></tr><tr><td><code>{{.origname}}</code></td><td>The media&rsquo;s original filename (if any)</td></tr><tr><td><code>{{.chatid}}</code></td><td>Chat ID of the message</td></tr></tbody></table><p>Examples:</p><pre tabindex=0><code># Fixed prefix + message id + date
/fnametmpl Image_{{.msgid}}_{{.msgdate}}.jpg
# Use original name if available, otherwise a generated name
/fnametmpl {{.origname}}
</code></pre><blockquote class="book-hint warning">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.</blockquote></article><footer class=book-footer><div class="flex flex-wrap justify-between"><div><a class="flex align-center" href=https://github.com/krau/saveany-bot/commit/c9bb6c9e3c325c83ffef5bbe4fa54a58b82de2df title='Last modified by krau | 2026/06/28' target=_blank rel=noopener><img src=/svg/calendar.svg class=book-icon alt>
<span>2026/06/28</span></a></div><div><a class="flex align-center" href=https://github.com/krau/saveany-bot/edit/main/docs/content/en/usage/config.md target=_blank rel=noopener><img src=/svg/edit.svg class=book-icon alt>
<span>Edit this page</span></a></div></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><div class=book-comments></div><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#config--user-configuration><code>/config</code> — User Configuration</a><ul><li><a href=#filename-strategy>Filename strategy</a></li><li><a href=#duplicate-file-strategy>Duplicate file strategy</a></li></ul></li><li><a href=#fnametmpl--custom-filename-template><code>/fnametmpl</code> — Custom Filename Template</a></li></ul></nav></div></aside></main></body></html>