DEV Community

Cover image for FileSearching With Python
Himanshu Bhatnagar
Himanshu Bhatnagar

Posted on

FileSearching With Python

Hi guys ...
I designed a python program for searching, Sending the files from the searched location to the newly created directory.

It can searches any file from any location also sending of permission restricted file is also possible(i don't exclude any dot files from the os.walk() function but the folders which don't contain anything in it or folders which don't have any file is excluded).

How FileSearching Works ??
-> So, the main working of FileSearching rely on some functions and modules i.e.,

  1. OS - This module helped me with its several functions so that i can be able to communicate with my operating system.

  2. Shutil - Helped in Sending Files from source to destination location.

  3. os.walk() - Helped in iterating over a list of folders, sub-directories, files.

  4. Regex - Helped in creating a pattern for searching that particular files(based on some extension ex. mp3, pdf, 7z, bz, mp4 and lot more).

These four masterpieces helped me to get my job perfectly done and there're also other functions but this Four is like a blueprint so that an end-user can understand how FileSearching works without even check every line of the code.

Project is still in development, If anybody needs to look the source code or test the project then he'll check my GitHub repo. of FileSearching ->

GitHub logo Himan10 / FileSearching

Make your file searching (Based on Extensions) more Accurate and Effective

What FileSearching is all about -

Well FileSearcing program provide you the better way to search your files( based on extension ) from anywhere in the system.

It also provide a copy of searched items in a newly created directory along with a file which consist of paths. Here path referred to that location where those items exist.

User need to provide the file extension and Location in order to search item and in return user have names/paths of searched items, and able to copy searched items.

For example :

input -> mp3
         location (/home/Downloads , /usr/bin)
output -> Names/Paths of mp3 files
                or
          Copy files to a newly created directory

How This Works -

-> OS - https://docs.python.org/3/library/os.html

-> Shutil - https://docs.python.org/3/library/shutil.html

-> Regex - https://docs.python.org/3/library/re.html

-> Sys - https://docs.python.org/3/library/sys.html

# -> os.walk()
os.walk() helps me to iterate over a list of folders, subfolders, files
Using os.walk(path) we




This is my first post in dev.to community ... So, Guys Please look at the repo. and provide suggestions for its improvement.

Thankyou.

Top comments (0)