Skip to main content

Find file or folder by Python, Faster than Windows File Explorer.

Project description

python_find_file_name

find file or dir location.

Install

pip install wfind

Warning

before you install this package, you should check no moudle named find:

#prevent python package name conflicts
import find
#Output: ModuleNotFoundError: No module named 'find'

Usage

python -m find "base_path" "file_or_directory_name"

python -m find --base_path "C:\" --pattern ".mp4"
python -m find --base_path "C:\" --pattern "mat" --mode "in" --folder
python -m find --base_path "C:\" --pattern ".png" --mode "in" --file
python -m find --base_path "C:\" --pattern ".pdf$" --mode "re"
python -m find --base_path "C:\" --pattern "*.jpg" --mode "fm" 

python -m find --help
usage: Python File Finder [-h] [-p BASE_PATH] [-d PATTERN] [-file] [-folder] [-m MODE]

Find File or Folder Name.

options:
  -h, --help            show this help message and exit
  -p, --base_path BASE_PATH
                        base path
  -d, --pattern PATTERN
                        dest pattern
  -file, --file         only search file
  -folder, --folder     only search folder
  -m, --mode MODE       mode: -m in, -m fm, -m re

find without base_path will use current directory

python -m find --pattern ".png"

import

"""
Usage:

find(pattern, path, prt=1, typeMode="both", matchMode="in")
finder(name, pattern, matchMode)
typeMode:
  both
  file
  folder
matchMode:
  in (in)
  re (regex)
  fm (fnmatch)
"""

import find
result = find.find(".so","/", prt=0)

Code (without installed)

import os, fnmatch

def find(pattern, path, prt=1):
    result = []
    for root, dirs, files in os.walk(path):
        for name in files:
            if fnmatch.fnmatch(name, pattern):
                result.append(os.path.join(root, name))
                if prt: print(result[-1])
        for name in dirs:
            if fnmatch.fnmatch(name, pattern):
                result.append(os.path.join(root, name))
                if prt: print(result[-1])
    return result

find('*yourfilenameordictname*', 'base_path')
find('*.jpg', r'C:\Users\原神\Downloads') #test on windows11, my computer.
find('*.txt', '/') #test on colab linux
find('*.jpg', '/content') #test on colab linux
find('*sample*', '/') #test on colab linux

print()

source and reference

https://stackoverflow.com/a/1724723/19470749
https://www.runoob.com/python/os-walk.html

Why I need this script?

I don't know where the huggingface download the model, and after search I know it download to cache folder, but I don't know where it is, so I directly use this script to search D drive and C drive, and then success find.

find("*text_encoder*", "D://")
find("*text_encoder*", "C://")

Notice, you can also set huggingface cache dir

pipe = CogVideoXImageToVideoPipeline.from_pretrained(model_id,text_encoder=text_encoder,transformer=transformer,vae=vae,torch_dtype=torch.float16,cache_dir="D://3")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wfind-0.0.4.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wfind-0.0.4-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file wfind-0.0.4.tar.gz.

File metadata

  • Download URL: wfind-0.0.4.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for wfind-0.0.4.tar.gz
Algorithm Hash digest
SHA256 e5c9bee8e608d5efd5e7856229571af1ff2b6985160c45916de9dfda90b2e8ad
MD5 faa3be386f99accc9a2aa9f96ffb8bc6
BLAKE2b-256 b5b3224ee002dfec2f4f2b3400da256f7b4835b262fb0c84870270d3b3ec4742

See more details on using hashes here.

File details

Details for the file wfind-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: wfind-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for wfind-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 35147f1431cf21c781c7b5cf6f35616fcd2b7653d2d18f9d660fa8c918460bbe
MD5 99f225b6a1eb93e9440a766d8df8477a
BLAKE2b-256 cf8fad3465590c6e2d930053c12887b3d45823f6ef8cdc66042d575e55d73ca8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page