AutoSaveScripts

버전 0.1 (4.39 KB) 작성자: thosman
Matlab function to periodically save modified scripts (including unsaved Untitled scripts) to a backup directory
다운로드 수: 7
업데이트 날짜: 2020/12/27

# AutoSaveScripts (see GitHub readme for better formatting)

Matlab function to periodically save modified scripts (including unsaved `Untitled` scripts) to a backup directory (organized by date and Matlab instance).

Typical use case is to call this function from startup.m such that this runs in the background.

## Need

Matlab may close before there is an opportunity to save modified functions/scripts (e.g. `Untitled` scripts), e.g. OS restart or Matlab crash.

This script will check and back up all unsaved files/scripts in the Matlab editor, to prevent data loss in case Matlab closing before the opportunity to save. That said, the script's main purpose is to handle backing up unsaved `Untitled` scripts because Matlab does not currently save or back up these scripts.

## Code header

Backup unsaved scripts (including unsaved `Untitled` scripts) to a backup directory every `autoSaveRefresh_sec`.

Backup instance folders are created and auto-incremented to handle multiple opened matlabs.

### Backup directory location

Example backup directory (with defaults):

Example OS path: `userpath`/backup/2020-12-26/MatlabInstance3/

Example path using param names: `backupDir`/`backupSubDirFormat`/`backupInstanceDir` `number`/

### Params / Debug

Params:

- `autoSaveRefresh_sec` [default `500`] Refresh time in seconds.
- `backupOnlyUntitled` [default `false`] If true, _only_ unsaved `Untitled` scripts are backed up. Otherwise, all unsaved files are backed up.

Debug flags:

- `debug.stopOnError` [default `false`] Stop (rethrow) if timer errors are encountered.
- `debug.keyboardOnError` [default `false`] Pause if timer errors are encountered (if true, will pause before the rethrowing the error).
- `debug.verbosePrints` [default `false`] Prints when creating the backup dir and saving backup scripts, see local function `DebugPrintf`.

## Testing

Testing on MATLAB 2019b, Windows OS

- All paths should be OS agnostic.
- Uses `matlab.desktop.editor` commands to access the editor which may be MATLAB version dependent.

인용 양식

thosman (2024). AutoSaveScripts (https://github.com/tommyhosman/AutoSaveScripts/releases/tag/v0.1), GitHub. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2019b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
0.1

이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.
이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.