-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PR for File_search script #316
Open
debojit11
wants to merge
6
commits into
DhanushNehru:master
Choose a base branch
from
debojit11:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+55
−0
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import pathlib | ||
all_files_path = pathlib.Path('Place the folder path here under quotes') | ||
file_paths = [] | ||
|
||
for file in all_files_path.rglob('*'): | ||
if file.is_file(): | ||
file_paths.append(str(file)) | ||
|
||
formatted_output = '[\n' + ',\n'.join(f' "{path}"' for path in file_paths) + '\n]' | ||
print(formatted_output) | ||
|
||
|
||
file_extensions = [] | ||
|
||
for file in all_files_path.rglob('*'): | ||
if file.is_file(): | ||
ext = file.suffix.lower() | ||
if ext and ext not in file_extensions: | ||
file_extensions.append(ext) | ||
|
||
|
||
formattedd_output = '[\n' + ',\n'.join(f' "{ext}"' for ext in file_extensions) + '\n]' | ||
print(formattedd_output) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
File Path Finder and Unique Extension Lister: | ||
This Python script searches a specified folder for all files, regardless of file type, within its directory and subdirectories. It outputs the paths of all files found and also lists all unique file extensions present in the folder. The script uses Python's pathlib module, which is cross-platform and simplifies working with file paths. | ||
|
||
Features: | ||
File Path Finder: The script scans a folder and lists the file paths of all files it finds within the specified directory and its subdirectories. | ||
Unique File Extension Lister: The script identifies all unique file extensions present in the folder, displaying them in lowercase format. | ||
|
||
Requirements: Python 3.x | ||
|
||
Set the Folder Path: | ||
|
||
Replace 'Place the folder path here under quotes' in the script with the path to the folder you want to scan: | ||
all_files_path = pathlib.Path('path/to/your/folder') | ||
|
||
Run the Script: | ||
|
||
Save the script as file_finder.py (or another name of your choice). | ||
Open your terminal or command prompt. | ||
Navigate to the folder containing the script and run it with: | ||
python file_finder.py | ||
|
||
Output: | ||
The script will output two lists: | ||
The first list contains the paths of all files found within the specified folder and its subdirectories. | ||
The second list contains all unique file extensions in the folder, displayed in lowercase. | ||
|
||
|
||
Example output: | ||
|
||
[ "path/to/folder/document.txt", "path/to/folder/image.jpg", "path/to/folder/subfolder/script.py"] | ||
[ ".txt", ".jpg", ".py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,6 +135,7 @@ Weight Converter | [Weight Converter](https://github.com/Wa | |
| Word to PDF | [Word to PDF](https://github.com/DhanushNehru/Python-Scripts/tree/master/Word%20to%20PDF%20converter) | A Python script to convert an MS Word file to a PDF file. | | ||
| Youtube Downloader | [Youtube Downloader](https://github.com/DhanushNehru/Python-Scripts/tree/master/Youtube%20Downloader) | Downloads any video from [YouTube](https://youtube.com) in video or audio format! | ||
| Youtube Playlist Info Scraper | [Youtube Playlist Info Scraper](https://github.com/DhanushNehru/Python-Scripts/tree/master/Youtube%20Playlist%20Info%20Scraper) | This python module retrieve information about a YouTube playlist in json format using playlist link. | ||
| File Search | [File_search](https://github.com/debojit11/Python-Scripts/tree/master/File_Search) | A python script that searches a specified folder for all files, regardless of file type, within its directory and subdirectories. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please put the row in the correct order. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, I will make the changes |
||
|
||
## Gitpod | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you consider improving the all the heading?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I will improve it