From efcfc585d7a396ff7983196a621256a64728438b Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sun, 1 Dec 2024 14:37:43 +0100 Subject: [PATCH] Added instructions for path independend execution --- README.md | 24 ++++++++++++++++++++++-- scan.py | 2 ++ 2 files changed, 24 insertions(+), 2 deletions(-) mode change 100644 => 100755 scan.py diff --git a/README.md b/README.md index 4ef2bdb..6bf9c41 100644 --- a/README.md +++ b/README.md @@ -20,12 +20,31 @@ The Directory Content Scanner is a Python-based utility designed to recursively cd directory-content-scanner ``` +### ⚡ Running Without Full Path Specification + +To execute the script directly from the terminal without typing the full path, follow these steps: + +#### 1. **Make the Script Executable** +Ensure the script is executable: +```bash +chmod +x scan.py +``` + +#### 2. **Create a Symbolic Link** +While inside the repository folder, use the following one-liner to create a symbolic link in a directory included in your `$PATH`: + +```bash +ln -s "$(pwd)/scan.py" ~/.local/bin/scan-directory +``` + +This command uses the current directory as the base for the symbolic link and points to `~/.local/bin/scan-directory`. + ## 📖 Usage Run the Python script, specifying the target directory and any desired filters: ```bash -python3 scan.py /path/to/directory [options] +scan-directory /path/to/directory [options] ``` ### Options: @@ -46,6 +65,7 @@ python3 scan.py /path/to/directory --help - `--path-contains`: Display files whose paths contain one of these strings. Useful for narrowing down the scan to specific parts of the directory structure. - `--content-contains`: Display files containing one of these strings in their content. The file's content will be checked, and only matching files will be shown. + ## ⚠️ Caution Exercise caution when scanning directories with large files. The script may produce extensive output. Always assess the data volume before executing the script. @@ -66,4 +86,4 @@ This project is licensed under the GNU Affero General Public License v3.0. The c ## 🙏 Acknowledgements -Special thanks to OpenAI's ChatGPT model for assistance. Dive deeper into the creation process [here](https://chat.openai.com/share/71e9bc9e-d34a-4b03-bf68-4f9e994d156a), [here](https://chat.openai.com/share/3fc66009-ff4e-425e-a4a3-fc703534885d) and [here](https://chatgpt.com/share/d08724c6-8f65-4b24-9828-e0f895bd1e1d). +Special thanks to OpenAI's ChatGPT model for assistance. Dive deeper into the creation process [here](https://chat.openai.com/share/71e9bc9e-d34a-4b03-bf68-4f9e994d156a), [here](https://chat.openai.com/share/3fc66009-ff4e-425e-a4a3-fc703534885d), [here](https://chatgpt.com/share/d08724c6-8f65-4b24-9828-e0f895bd1e1d) and [here](https://chatgpt.com/share/674c665d-acf8-800f-bd42-5eb7bd566f1e). diff --git a/scan.py b/scan.py old mode 100644 new mode 100755 index 1909b92..381443c --- a/scan.py +++ b/scan.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import os import argparse import re