I tried searching for files under the folder with Python by file name

Source code

import subprocess
import glob
import pathlib

def find(url, fil):
        share = pathlib.WindowsPath(url)
        try:
                if share.exists():
                        print(url)
                        for x in share.glob(fil):
                                print(str(x).replace(url, ''))
                return True
        except:
                import traceback
                traceback.print_exc()
                input("Press Enter to continue...")
                return False

def doFunc():
        print('Please enter a search keyword')
        word = input()

        if word:
                print('Keyword "'+word+'] Is being searched.')
                url = r'D:\\Target folder'
                fil = '**/[!(~$)]*' + word + '*.*'
                return find(url,fil)
        else:
                return True

        input("The search is complete.\n Press the Enter key to end the process.")


while doFunc():
        print('Continue processing!\n'+"-"*100)

Recommended Posts

I tried searching for files under the folder with Python by file name
[Python] I tried substituting the function name for the function name
I tried to open the latest data of the Excel file managed by date in the folder with Python
I tried to divide the file into folders with Python
I tried to refer to the fun rock-paper-scissors poi for beginners with Python
A memo organized by renaming the file names in the folder with python
[Python] Get the files in a folder with Python
vprof --I tried using the profiler for Python
I tried "differentiating" the image with Python + OpenCV
I tried python programming for the first time.
I tried "binarizing" the image with Python + OpenCV
I tried using the Datetime module by Python
Python script that makes UTF-8 files with all BOMs under the folder without BOMs
I tried Python on Mac for the first time.
I tried to solve the soma cube with python
Python program that looks for the same file name
I tried to solve the problem with Python Vol.1
I tried hitting the API with echonest's python client
I tried fp-growth with python
I tried scraping with Python
I tried gRPC with Python
I tried scraping with python
I tried to find the entropy of the image with python
I tried "gamma correction" of the image with Python + OpenCV
I tried to simulate how the infection spreads with Python
[Python] Open the csv file in the folder specified by pandas
I tried using the Python library from Ruby with PyCall
Miscellaneous notes that I tried using python for the matter
Try to decipher the garbled attachment file name with Python
Extract the xz file with python
I tried web scraping with python.
I liked the tweet with python. ..
I tried running prolog with python 3.8.2.
I tried SMTP communication with Python
I tried scraping the ranking of Qiita Advent Calendar with Python
I tried to solve the ant book beginner's edition with python
I tried using the python module Kwant for quantum transport calculation
[System trade] I tried playing with Stochastic Oscillator by decomposing with python ♬
I made a lot of files for RDP connection with Python
[Pandas] I tried to analyze sales data with Python [For beginners]
For the time being, I want to convert files with ffmpeg !!
I tried to improve the efficiency of daily work with Python
I tried running the TensorFlow tutorial with comments (_TensorFlow_2_0_Introduction for beginners)
[Python] I tried to visualize the night on the Galactic Railroad with WordCloud!
I tried moving the image to the specified folder by right-clicking and left-clicking
I tried to communicate with a remote server by Socket communication with Python.
I tried tensorflow for the first time
List all files under the current directory line by line with full path
I tried scraping Yahoo News with Python
Check the existence of the file with python
[Python] Get the variable name with str
I tried sending an email with python.
765 I tried to identify the three professional families by CNN (with Chainer 2.0.0)
Download the file by specifying the download destination with Python & Selemiun & Chrome (Windows version)
Let's read the RINEX file with Python ①
I tried to get the authentication code of Qiita API with Python.
If you are told cannot by Python import, review the file name
Read the file line by line in Python
Download files on the web with Python
I tried a functional language with Python
I tried recursion with Python ② (Fibonacci sequence)