https://github.com/carlosulisesochoa/path-as-a-comment-powershell
PowerShell script that automatically inserts the file path as a comment at the top of each compatible file.
https://github.com/carlosulisesochoa/path-as-a-comment-powershell
path-as-a-comment powershell script scripting windows
Last synced: about 2 months ago
JSON representation
PowerShell script that automatically inserts the file path as a comment at the top of each compatible file.
- Host: GitHub
- URL: https://github.com/carlosulisesochoa/path-as-a-comment-powershell
- Owner: CarlosUlisesOchoa
- License: mit
- Created: 2023-05-01T22:02:02.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-06T16:58:19.000Z (about 3 years ago)
- Last Synced: 2025-05-23T19:37:37.399Z (about 1 year ago)
- Topics: path-as-a-comment, powershell, script, scripting, windows
- Language: PowerShell
- Homepage:
- Size: 8.79 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This script automatically inserts the file path as a comment at the top of each compatible file. This helps developers quickly identify the location of a file while preventing any malfunctions (because the path is added as a comment)
## Table of Contents
- [System Requirements](#system-requirements)
- [Usage](#usage)
- [Supported file extensions](#supported-file-extensions)
- [License](#license)
- [About developer](#about-developer)
## System Requirements
- Windows OS (tested on Windows 10 and 11)
- PowerShell 5.1 or later
## Usage
1. [Download](https://raw.githubusercontent.com/CarlosUlisesOchoa/Path-as-a-comment-PowerShell/main/add-path.ps1) the `add-path.ps1` script.
2. Save the script to a directory on your computer.
3. Open PowerShell and navigate to the directory where the script is saved.
4. Run the script with the `-d` parameter and specify the directory
Example:
PowerShell:
```PowerShell
.\add-path.ps1 -d "C:\your_directory"
```
## Supported file extensions
The script supports the following file extensions. It adds their corresponding comment syntax:
- *.js
- *.jsx
- *.ts
- *.tsx
- *.sass
- *.less
- *.scss
- *.php
- *.java
- *.py
- *.rb
- *.css
For file extensions not included above, the script will not modify the file.
## Example
Let's say we have a directory `C:\your_directory` with the following structure:
```
your_directory
│
└───js
│ │ script.js
│ │
│ └───lib
│ library.js
│
└───css
style.css
```
After running the script, the files will have their file paths inserted as comments:
`script.js`:
```javascript
// your_directory\js\script.js
... (rest of the file content)
```
`library.js`:
```javascript
// your_directory\js\lib\library.js
... (rest of the file content)
```
`style.css`:
```css
/* your_directory\css\style.css */
... (rest of the file content)
```
## License
This project is released under the [MIT License](LICENSE).
## About developer
Visit my web [Carlos Ochoa](https://carlos8a.com)
---
**Note:** If you encounter any issues with the script, please report them [here](https://github.com/CarlosUlisesOchoa/Path-as-a-comment-PowerShell/issues). Contributions are welcome!