diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2013-03-24 21:11:02 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2013-03-24 21:11:02 +0200 |
commit | a05021f7495f57f103eff7154b60441865de48cf (patch) | |
tree | dfe7161afd022b8f27ed2a3268ccb0b3a7347746 /delwithsuffix.py | |
parent | 6bbaba5a8230003fca393ad8ccc3971f2b2f349e (diff) | |
download | meson-a05021f7495f57f103eff7154b60441865de48cf.zip meson-a05021f7495f57f103eff7154b60441865de48cf.tar.gz meson-a05021f7495f57f103eff7154b60441865de48cf.tar.bz2 |
Helper app to delete files with a given suffix.
Diffstat (limited to 'delwithsuffix.py')
-rwxr-xr-x | delwithsuffix.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/delwithsuffix.py b/delwithsuffix.py new file mode 100755 index 0000000..900d01b --- /dev/null +++ b/delwithsuffix.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 + +# Copyright 2013 Jussi Pakkanen + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os, sys + +if len(sys.argv) != 3: + print('%s <root of subdir to process> <suffix to delete>' % sys.argv[0]) + sys.exit(1) + +topdir = sys.argv[1] +suffix = sys.argv[2] +if suffix[0] != '.': + suffix = '.' + suffix + +for (root, dirs, files) in os.walk(topdir): + for f in files: + if f.endswith(suffix): + fullname = os.path.join(root, f) + os.unlink(fullname) |