diff options
author | Iru Cai <mytbk920423@gmail.com> | 2018-08-25 00:16:14 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2018-08-25 00:17:27 +0800 |
commit | d85513c6f24968abd35181c902819dc8e489f7e7 (patch) | |
tree | 72d3561c42af8dde758788da35ef77c98c201684 /mxclean/clean_files.cpp | |
parent | e5fab7b6ee72d8c7b9701bc1e007a875a37c2f2c (diff) | |
download | matrix-synapse-scripts-d85513c6f24968abd35181c902819dc8e489f7e7.tar.xz |
Diffstat (limited to 'mxclean/clean_files.cpp')
-rw-r--r-- | mxclean/clean_files.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/mxclean/clean_files.cpp b/mxclean/clean_files.cpp new file mode 100644 index 0000000..8c3b0ad --- /dev/null +++ b/mxclean/clean_files.cpp @@ -0,0 +1,43 @@ +#include <set> +#include <string> +#include <fstream> +#include <iostream> + +using namespace std; + +string path_to_id(string &s) +{ + string t = ""; + for (auto c: s) { + if (isalpha(c)) + t = t + c; + } + return t; +} + +int main() +{ + ifstream flist("/tmp/mxclean/filelist"); + ifstream keeplist("/tmp/mxclean/files_to_keep"); + ofstream rm("/tmp/mxclean/remove.sh"); + + set<string> keep_set; + string s; + int keep = 0, remove = 0; + + while (keeplist >> s) { + keep_set.insert(s); + } + + while (flist >> s) { + if (keep_set.find(path_to_id(s)) != keep_set.end()) { + keep++; + } else { + remove++; + rm << "rm " << s << endl; + } + } + + cout << "keep " << keep << " files, remove " << remove << " files." << endl; + return 0; +} |