# script to "restore" all staggered files

**URL:** https://forum.syncthing.net/t/script-to-restore-all-staggered-files/16535
**Category:** Support
**Created:** [March 20, 2021, 12:09am UTC](https://forum.syncthing.net/t/script-to-restore-all-staggered-files/16535 "2021-03-20T00:09:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![cregox](https://forum.syncthing.net/user_avatar/forum.syncthing.net/cregox/32/9153_2.png) [@cregox](https://forum.syncthing.net/u/cregox)
#### Post date: [March 20, 2021, 12:09am UTC](https://forum.syncthing.net/t/script-to-restore-all-staggered-files/16535/1 "2021-03-20T00:09:41Z")

</div>

i keep running into sync issues when i move folders around.

so, long ago, i decided to keep staggered in both nodes.

they were working good until yesterday. mostly i don’t need to worry about the dreadful `.stversions` folder and when i do i just go to the gui and restore all latest versions, usually.

don’t know why, but now the gui in both nodes gets stuck on “loading data” when i hit “versions”.

the .stversions folder have 10gb, which i think of unusual, but i also think it went bigger than that before without this issue.

i now realize that probably for my case, trash would serve me nearly as well.

but i do enjoy to have the older versions. gives me a peace of mind, even if it’s not really meant to be a backup - it’s still me “backupish” than trash. and i guess i have used it once or twice.

then i found this interesting script

> [@Syncthing deleted 67000 files, how do I restore?](https://forum.syncthing.net/t/syncthing-deleted-67000-files-how-do-i-restore/9896/2):
>
> Since you’re on Linux, you can do batch rename using linux tools, something like: #!/bin/bash for file in $(find /yourpath/ -type f -regextype posix-awk -regex ".\*~[0-9]{8}-[0-9]{6}.\*") do mv $file ${file::-16} done The script is based on the naming patterns used with staggered versioning, i don’t know if other versioning patterns create same filenames in .stversions. The script above recursively searches for files in a given path and its sub-directories for files named somename~12345678-1…

but it’s still not quite what i need. plus it’ll probably break when there’s more than one version of the same file…

anyway…

tl;dr;

could you please share a script which will just delete all staggered files and keep the newest? newest between staggered and current, very much like the gui works, of course. 😁

---

<div class="post-metadata">

### Author: ![cregox](https://forum.syncthing.net/user_avatar/forum.syncthing.net/cregox/32/9153_2.png) [@cregox](https://forum.syncthing.net/u/cregox)
#### Post date: [March 27, 2021, 6:21am UTC](https://forum.syncthing.net/t/script-to-restore-all-staggered-files/16535/2 "2021-03-27T06:21:20Z")

</div>

i think this link might eventually lead to an answer, in case i forget to update it here:

> **[r/termux - bash script for loop failing on spaced file names](https://www.reddit.com/r/termux/comments/mdk3bc/bash_script_for_loop_failing_on_spaced_file_names/)**
>
> 6 votes and 3 comments so far on Reddit

---

<div class="post-metadata">

### Author: ![system](https://forum-uploads.syncthingcdn.net/original/2X/0/0b50e0a202b22ae6a67190759e8c868805b8ed9f.png) [@system](https://forum.syncthing.net/u/system)
#### Post date: [April 26, 2021, 6:22am UTC](https://forum.syncthing.net/t/script-to-restore-all-staggered-files/16535/3 "2021-04-26T06:22:18Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
