forked from iam-veeramalla/python-for-devops
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cbe8862
commit 3ba1f93
Showing
5 changed files
with
38 additions
and
1 deletion.
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 @@ | ||
folder_paths = input("Enter a list of folder paths separated by spaces: ").split() |
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,10 @@ | ||
def main(): | ||
folder_paths = input("Enter a list of folder paths separated by spaces: ").split() | ||
print(folder_paths) | ||
|
||
# Print elements in the list | ||
#for folder_path in folder_paths: | ||
# print(folder_path) | ||
|
||
if __name__ == "__main__": | ||
main() |
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,25 @@ | ||
import os | ||
|
||
def list_files_in_folder(folder_path): | ||
try: | ||
files = os.listdir(folder_path) | ||
return files, None | ||
except FileNotFoundError: | ||
return None, "Folder not found" | ||
except PermissionError: | ||
return None, "Permission denied" | ||
|
||
def main(): | ||
folder_paths = input("Enter a list of folder paths separated by spaces: ").split() | ||
|
||
for folder_path in folder_paths: | ||
files, error_message = list_files_in_folder(folder_path) | ||
if files: | ||
print(f"Files in {folder_path}:") | ||
for file in files: | ||
print(file) | ||
else: | ||
print(f"Error in {folder_path}: {error_message}") | ||
|
||
if __name__ == "__main__": | ||
main() |
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 @@ | ||
# Lists Part-2 |
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