0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

zipファイルを探すときのために

Last updated at Posted at 2021-05-26

あのzipファイル、どこに置いたっけ、
使っていないzipファイルを探して削除したい、
そんなときのために。

WindowsのCドライブ以下を探す場合を想定しています。

search_zip_file.py
import os
import pathlib

def get_path_recursive(path):
    for p in path.iterdir():
        try:
            if p.is_dir():
                get_path_recursive(p)
            elif p.is_file():
                if p.suffix == '.zip':
                    print(f'{p}')
        except PermissionError:
            pass
        except OSError:
            pass

path = pathlib.Path('C:\\')
get_path_recursive(path)
0
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?