diff --git a/CommandLineArgument/Argument.py b/CommandLineArgument/Argument.py new file mode 100644 index 0000000..994ca1a --- /dev/null +++ b/CommandLineArgument/Argument.py @@ -0,0 +1,55 @@ +import os +import argparse +def open_file(): + try: + file_path = input("Enter the path to the file: ") + os.startfile(file_path) + except Exception as e: + print(f"Error opening file: {e}") + + + + + + +def create_folder(): + folder_path = input("Enter the path to the folder: ") + folder_name = input("Enter the name of the folder: ") + try: + os.makedirs(os.path.join(folder_path, folder_name), exist_ok=True) + print(f"Folder '{folder_name}' created successfully.") + except Exception as e: + print(f"Error creating folder: {e}") + + +def write_to_file(): + file_path = input("Enter the name of the file: ") + file_name = os.path.basename(file_path) + try: + with open(file_path, 'w') as f: + f.write(input("Enter the text to be written to the file: ")) + print(f"File '{file_name}' created successfully.") + except Exception as e: + print(f"Error writing to file: {e}") + + +def main(): + + parseer = argparse.ArgumentParser(description="Command Line Argumet") + parseer.add_argument("-w", "--write", help="write to a file", action="store_true") + parseer.add_argument("-o", "--open", help="open a file", action="store_true") + parseer.add_argument("-c", "--create", help="create a new folder", action="store_true") + args = parseer.parse_args() + if args.write: + write_to_file() + elif args.open: + open_file() + elif args.create: + create_folder() + + + else: + print("Invalid input. Please try again.") + +if __name__== "__main__": + main() \ No newline at end of file diff --git a/CommandLineArgument/README.md b/CommandLineArgument/README.md new file mode 100644 index 0000000..1fefa2c --- /dev/null +++ b/CommandLineArgument/README.md @@ -0,0 +1,31 @@ +# File Management Tool + +A simple command-line tool for managing files and folders in Python. This tool allows users to create folders, open files, and write content to files through command-line arguments. + +## Features + +- **Open a File**: Opens a specified file using the default application. +- **Create a Folder**: Creates a new folder at a specified location. +- **Write to a File**: Creates a new file or overwrites an existing one with user-provided text. + +## Requirements + +- Python 3.x +- os +- argparse + +## Usage + +### Command Line Arguments + +You can use the following command-line arguments to execute different functionalities: + +- `-o` or `--open`: Opens a specified file. +- `-c` or `--create`: Creates a new folder. +- `-w` or `--write`: Writes to a specified file. + +### Examples + +1. **To Open a File:** + ```bash + name_of_the_file -o diff --git a/CommandLineArgument/run.txt b/CommandLineArgument/run.txt new file mode 100644 index 0000000..8fe9995 --- /dev/null +++ b/CommandLineArgument/run.txt @@ -0,0 +1 @@ +Yeah!! \ No newline at end of file diff --git a/NASA_Image_Extraction/Astro_Images/2022-11-25_NGC 6744: Extragalactic Close-Up.mp3 b/NASA_Image_Extraction/Astro_Images/2022-11-25_NGC 6744: Extragalactic Close-Up.mp3 deleted file mode 100644 index f5611fc..0000000 Binary files a/NASA_Image_Extraction/Astro_Images/2022-11-25_NGC 6744: Extragalactic Close-Up.mp3 and /dev/null differ