Skip to main content

Shell utility resembling findutils, small, extendable and windows-friendly

Project description

pyfindlib

Shell utility resembling findutils. Small, extendable and Windows-friendly.

Install

pip install pyfindlib

Use

usage: pyfind [PATHS] [OPTIONS] [PREDICATES] [ACTION]

finds files and dirs that satisfy predicates and executes action

options:
  -maxdepth NUMBER     walk no deeper than NUMBER levels
  -output PATH         output to file instead of stdout
  -append              append to file instead of rewrite
  -trail               print trailing slash on directories
  -cdup NUMBER         print (or perform action on) parent path (strip NUMBER 
                       trailing components from path)
  -first NUMBER        print (or perform action on) first NUMBER found items and stop

predicates:
  -type d              is directory
  -type f              is file
  -mtime DAYS          if DAYS is negative: modified within DAYS days, 
                       if positive modified more than DAYS days ago
  -ctime DAYS          same as -mtime, but when modified metadata not content
  -mmin MINUTES        if MINUTES is negative: modified within MINUTES minutes, 
                       if positive modified more than MINUTES minutes ago
  -mdate DATE1 [DATE2] modified at DATE1 (or between DATE1 and DATE2)
  -cmin MINUTES        same as -mmin, but when modified metadata not content
  -newer PATH/TO/FILE  modified later than PATH/TO/FILE
  -newermt DATETIME    modified later than DATETIME
  -newerct DATETIME    same as -newermt but when modified metadata not content
  -name PATTERNS       filename matches one of PATTERNS (wildcard)
  -iname PATTERNS      same as -name but case insensitive
  -path PATTERNS       file path matches one of PATTERNS (wildcard)
  -ipath PATTERNS      same as -path but case insensitive
  -grep PATTERN        file content contains one of PATTERNS (regexp)
  -igrep PATTERN       same as -grep but case insensitive
  -bgrep PATTERN       same as -grep but PATTERN is string of hex values
  -docgrep PATTERN     grep odt and ods files for PATTERN
  -xlgrep ...ARGS      grep xls files for values, each arg is one of: address range (c1:c10), 
                       numeric value (40.8), numeric range (40..41) or string (foo)
  -cpptmp              temporary cpp files (build artifacts - objects, generated code)
  -gitdir              directory with .git in it
  -zippath PATTERNS    zip containing file with path that matches one of PATTERNS (wildcard)
  -zipipath PATTERNS   same as -zippath but PATTERNS are case insensitive

predicates can be inverted using -not, can be grouped together in boolean expressions 
using -or and -and and parenthesis
          
actions:
  -print               print matched paths to output (default action)
  -delete              delete matched file
  -exec COMMAND ;      execute COMMAND
  -touch               touch file (set mtime to current time)
  -gitstat             print git status summary
  -copy DST            copy file to DST
  -move DST            move file to DST 

print action options:
  -abspath             print absolute paths
  -basename            print basename
  -stat                print paths with file size and modification date

exec action options:
  -async               execute asyncronously (do not wait for termination)
  -xargs               execute command once with all matched files as arguments
  -conc NUMBER         concurrency limit for -async -exec, 
                       defaults to number of cpu cores

exec action bindings:
  {}          path to file
  {path}      path to file
  {name}      name with extension
  {ext}       extension
  {basename}  name without extension
  {dirname}   directory name

copy and move action options:
  -tree                copy (move) preserving relative path (default)
  -flat                copy (move) without preserving relative path
  -skip                skip existing files (files are compared by size and name)
  -rename              rename files to avoid overwriting existing files

examples:
  pyfind -iname *.py -mmin -10
  pyfind -iname *.cpp *.h -not ( -iname moc_* ui_* )
  pyfind -iname *.h -exec pygrep -H class {} ;
  pyfind -iname *.o -delete
  pyfind -iname *.py -xargs -exec pywc -l ;
  pyfind D:\dev -iname node_modules -type d -cdup 1
  pyfind -iname *.dll -cdup 1 -abspath | pysetpath -o env.bat
  pyfind -iname *.mp3 -conc 4 -async -exec ffmpeg -i {} {dirname}\{basename}.wav ;
  pyfind -mdate 2024-07-25
  pyfind -mdate 2024-07-25 2024-08-21
  pyfind -newer path/to/file
  pyfind D:\dev -maxdepth 2 -gitdir -gitstat
  pyfind D:\dev -maxdepth 2 -stat
  pyfind C:\Qt\6.7.1 -iname *.dll -bgrep "5571feff"
  pyfind D:\w -xlgrep c1:c10 30.8 40..41 foo
  pyfind -iname *.txt -xargs -exec 7z a texts.zip ;
  pyfind -iname *.txt -xargs -exec copy {} dst ;
  pyfind -zipipath *.mtl
  pyfind D:\dl -iname *.jpg -copy E:\backup\dl -skip

See also

https://github.com/mugiseyebrows/mugi-cli

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

pyfindlib-0.0.4.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

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

pyfindlib-0.0.4-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyfindlib-0.0.4.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for pyfindlib-0.0.4.tar.gz
Algorithm Hash digest
SHA256 06bc32c9fb5520cda2406b6cc9dd87143018788e8c75da51bba493b85e4f3360
MD5 c3b421330363bedcb59b950f9e79d1d2
BLAKE2b-256 b74caad02ba5fd64c3c5c2a8282d6544ee1ca1cb1d3f5582487f86b7d4faefb3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyfindlib-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for pyfindlib-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d52419703902fe7263498cdbea36b50a68dc87f3bba45a74f249079228464b33
MD5 368e4c9994288c6b8e5810fc08714cb7
BLAKE2b-256 caca4c63bb435ac257cc1900ecb736d9aeec14bf649b6e818a13270f96cbcd34

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