├── LICENSE ├── README.md └── cleanremotes /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 88lex 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cleanremotes 2 | 3 | cleanremotes accepts a command line filter now. e.g. `./cleanremotes tv` will 4 | only clean remotes that have `tv` in them 5 | 6 | In order to permanently delete items from Trash you need to have Manager permissions on the 7 | Team Drive. Content Manager and below cannot permanently delete Trash. 8 | 9 | This script first runs rclone listremotes. Then for every remote that is configured in rclone 10 | the script runs the following commands: 11 | 12 | rclone dedupe (eliminates exact duplicates) 13 | 14 | rclone rmdirs (deletes empty directories) 15 | 16 | rclone delete source --drive-trashed-only --drive-use-trash=false -v (permanently deletes all trash from the source - be very careful with this) 17 | 18 | 19 | Be sure you know what each of these commands do before you run them. See rclone.org and read through the commands or forum for more information 20 | 21 | Add a hash # at the beginning of any line you wish to omit 22 | -------------------------------------------------------------------------------- /cleanremotes: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # cleanremotes accepts a command line filter now. e.g. `./cleanremotes tv` will 3 | # only clean remotes that have `tv` in them 4 | # cleanremotes also passes through any rclone flags you add after the filter 5 | # usage: ./cleanremotes filter --flag1 --flag2 6 | 7 | filter="$1" 8 | shift 9 | rc_flags="$@" 10 | timeout=5m 11 | #rclone listremotes | gawk "$filter" 12 | rclone listremotes | grep "$filter" 13 | 14 | readarray mounts < <( rclone listremotes | grep "$filter" ) 15 | for i in ${mounts[@]}; do 16 | echo; echo STARTING DEDUPE of identical files from $i; echo 17 | rclone dedupe skip $i -v --drive-use-trash=false --tpslimit=4 --tpslimit-burst=32 --transfers=16 $rc_flags 18 | echo; echo PERMANENTLY DELETING TRASH from $i; echo 19 | rclone cleanup $i -v $rc_flags 20 | timeout "$timeout" rclone delete $i -v --drive-trashed-only=true --drive-use-trash=false --tpslimit=4 --tpslimit-burst=32 --transfers=16 $rc_flags 21 | echo; echo REMOVING EMPTY DIRECTORIES from $i; echo 22 | timeout "$timeout" rclone rmdirs $i -v --drive-trashed-only=true --drive-use-trash=false --tpslimit=4 --tpslimit-burst=32 --transfers=16 $rc_flags 23 | done 24 | --------------------------------------------------------------------------------