# 修改儲存位置

## 預設儲存位置

Cherry Studio 數據儲存遵循系統規範，數據會自動放喺用戶目錄底下，具體目錄位置如下：

> macOS: /Users/username/Library/Application Support/CherryStudioDev

> Windows: C:\Users\username\AppData\Roaming\CherryStudio

> Linux: /home/username/.config/CherryStudio

亦可以喺以下位置睇到：

<figure><img src="https://2742912793-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0Ut5BptC3t8CtSU1UWpM%2Fuploads%2Fgit-blob-cabbab08e76218533ab0daca8115bb4b1824c5b7%2Fimage%20(31).png?alt=media" alt=""><figcaption></figcaption></figure>

## 修改儲存位置（供參考）

方法一：

可以通過建立軟連結嘅方式嚟實現。將軟件退出，將數據移動到你想保存嘅位置，然後喺原位置建立一個連結指向搬去後嘅位置就得。

具體操作步驟可以參考：<https://github.com/CherryHQ/cherry-studio/issues/621#issuecomment-2588652880>

方法二：\
基於 Electron 應用特點、通過配置啟動參數去修改儲存位置。

> \--user-data-dir\
> 例如: Cherry-Studio-\*-x64-portable.exe --user-data-dir="%user\_data\_dir%"

> 例子：

```shell
PS D:\CherryStudio> dir


    目錄: D:\CherryStudio


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         2025/4/18     14:05                user-data-dir
-a----         2025/4/14     23:05       94987175 Cherry-Studio-1.2.4-x64-portable.exe
-a----         2025/4/18     14:05            701 init_cherry_studio.bat
```

> init\_cherry\_studio.bat（編碼：ANSI）

```bash
@title CherryStudio 初始化
@echo off

set current_path_dir=%~dp0
@echo 當前路徑:%current_path_dir%
set user_data_dir=%current_path_dir%user-data-dir
@echo CherryStudio 數據路徑:%user_data_dir%

@echo 喺當前路徑搵 Cherry-Studio-*-portable.exe
setlocal enabledelayedexpansion

for /f "delims=" %%F in ('dir /b /a-d "Cherry-Studio-*-portable*.exe" 2^>nul') do ( #呢段代碼適配 GitHub 同官網下載版本，其他請自行修改
    set "target_file=!cd!\%%F"
    goto :break
)
:break
if defined target_file (
    echo 已搵到文件: %target_file%
) else (
    echo 未搵到匹配文件，退出呢個腳本
    pause
    exit
)

@echo 請確認後繼續
pause

@echo 啟動 CherryStudio
start %target_file% --user-data-dir="%user_data_dir%"

@echo 操作完成
@echo on
exit
```

> 目錄 user-data-dir 初始化後結構：

```shell
PS D:\CherryStudio> dir .\user-data-dir\


    目錄: D:\CherryStudio\user-data-dir


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         2025/4/18     14:29                blob_storage
d-----         2025/4/18     14:07                Cache
d-----         2025/4/18     14:07                Code Cache
d-----         2025/4/18     14:07                Data
d-----         2025/4/18     14:07                DawnGraphiteCache
d-----         2025/4/18     14:07                DawnWebGPUCache
d-----         2025/4/18     14:07                Dictionaries
d-----         2025/4/18     14:07                GPUCache
d-----         2025/4/18     14:07                IndexedDB
d-----         2025/4/18     14:07                Local Storage
d-----         2025/4/18     14:07                logs
d-----         2025/4/18     14:30                Network
d-----         2025/4/18     14:07                Partitions
d-----         2025/4/18     14:29                Session Storage
d-----         2025/4/18     14:07                Shared Dictionary
d-----         2025/4/18     14:07                WebStorage
-a----         2025/4/18     14:07             36 .updaterId
-a----         2025/4/18     14:29             20 config.json
-a----         2025/4/18     14:07            434 Local State
-a----         2025/4/18     14:29             57 Preferences
-a----         2025/4/18     14:09           4096 SharedStorage
-a----         2025/4/18     14:30            140 window-state.json
```
