Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6050d0f

Browse files
Merge pull request avinashkranjan#2096 from srujana-16/file_search
File search python script added - GSSOC'23
2 parents f0b4544 + 8bce691 commit 6050d0f

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

‎File Search/File_Search.py‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import os
2+
3+
def search_files(directory, extension):
4+
found_files = []
5+
for root, dirs, files in os.walk(directory):
6+
for file in files:
7+
if file.endswith(extension):
8+
found_files.append(os.path.join(root, file))
9+
return found_files
10+
11+
def main():
12+
print("File Search")
13+
print("-----------")
14+
directory = input("Enter the directory to search: ")
15+
extension = input("Enter the file extension to search for (e.g., .txt, .jpg): ")
16+
17+
found_files = search_files(directory, extension)
18+
19+
if found_files:
20+
print("Found files:")
21+
for file in found_files:
22+
print(file)
23+
else:
24+
print("No files with the specified extension were found.")
25+
26+
if __name__ == "__main__":
27+
main()
28+

‎File Search/README.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# File Search
2+
3+
This Python script allows you to search for files with a specific extension in a directory. It recursively searches through all subdirectories of the specified directory and returns a list of files that match the provided file extension.
4+
5+
## Setup instructions
6+
7+
1. Clone the repository or download the `file_search.py` file.
8+
9+
2. Open a terminal or command prompt and navigate to the directory where `file_search.py` is located.
10+
11+
3. Run the script by executing the following command: `python File_Search.py`
12+
13+
4. Follow the prompts to enter the directory to search and the file extension to search for.
14+
15+
## Output
16+
17+
The script will search for files with the specified extension and display their paths. If no files are found, it will display a message indicating that no files were found.
18+
19+
## Author(s)
20+
21+
Srujana
22+
23+

‎SCRIPTS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,5 @@
109109
| 107\. | ISBN Number Validator Script | Full form of ISBN number - International Standard Book Numbers. This python script can verify the entered number is valid isbn number or not. | [Take Me](./ISBN-Number-Validator/) | [Avdhesh Varshney](https://github.com/Avdhesh-Varshney)
110110
| 107\. | Image Classification | This script performs image classification using the MobileNetV2 pre-trained model provided by TensorFlow. It allows you to classify images into different categories based on the ImageNet dataset. | [Take Me](https://github.com/avinashkranjan/Amazing-Python-Scripts/tree/master/Image\Classification) | [Srujana Vanka](https://github.com/srujana-16)
111111
| 108\. | Check External IP Address | This is a basic Python script for determining your external IP address. | [Take Me](./Check_External_IP) | [Sabhi Sharma](https//github.com/sabhisharma-ise)
112+
| 109\. | File Searcher | The File Search script is a Python tool that allows you to search for files with a specific extension in a directory. It recursively searches through all subdirectories of the specified directory and returns a list of files that match the provided file extension. | [Take Me](https://github.com/avinashkranjan/Amazing-Python-Scripts/tree/master/File\Search) | [Srujana Vanka](https://github.com/srujana-16)
112113

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /