Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ArthurGareginyan/space_to_underscore
Recursively replace spaces with underscores (or vice versa) in file and directory names.
https://github.com/ArthurGareginyan/space_to_underscore
script shell-script
Last synced: 3 months ago
JSON representation
Recursively replace spaces with underscores (or vice versa) in file and directory names.
- Host: GitHub
- URL: https://github.com/ArthurGareginyan/space_to_underscore
- Owner: ArthurGareginyan
- License: mit
- Created: 2014-06-24T17:13:24.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-01-29T15:28:03.000Z (almost 2 years ago)
- Last Synced: 2024-07-19T02:15:47.372Z (4 months ago)
- Topics: script, shell-script
- Language: Shell
- Homepage:
- Size: 32.2 KB
- Stars: 18
- Watchers: 3
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Space to Underscore - Shell script
`space_to_underscore.sh` is a safe solution to recursively replace spaces with underscores (or vice versa) in file and directory names, starting from the current directory and to any subdirectories.
> Recursively - operating on a directory and its contents, including the contents of any subdirectories.
## Example
Before:
```
tree
.
|-- a dir
| `-- file with spaces.txt
`-- b dir
|-- another file with spaces.txt
`-- yet another file with spaces.pdf
```After:
```
tree
.
|-- a_dir
| `-- file_with_spaces.txt
`-- b_dir
|-- another_file_with_spaces.txt
`-- yet_another_file_with_spaces.pdf
```## Usage
> **Note!** To recursively replace underscores with spaces instead of spaces with underscores, follow the same steps, but using the `underscore_to_space.sh` file instead of `space_to_underscore.sh`.
1. Before you run the script, you must set the script executable permission. This is done only once, before the very first run of the script.
```
chmod +x space_to_underscore.sh
```2. Go to the directory where you want to rename files and directories recursively (starting from the current directory and to any subdirectories).
```
cd /home/user/example
```3. Run the `space_to_underscore.sh`.
```
~/space_to_underscore.sh
```> **Note!** In the example above, the `space_to_underscore.sh` file is located in the user home directory (`~/`). Change it according to the location of the file in your case.
## Contributing
Welcome and thanks! I appreciate you taking the initiative to contribute to this project.
Contributing isn’t limited to just code. I encourage you to contribute in the way that best fits your abilities, by writing tutorials, making translation to your native language, giving a demo at your local meetup, helping other users with their support questions, or revising the documentation for this project.
Please take a moment to read the guidelines in the [CONTRIBUTING.md](CONTRIBUTING.md). Following them helps to communicate that you respect the time of the other contributors to the project. In turn, they’ll do their best to reciprocate that respect when working with you, across timezones and around the world.
## Security Vulnerabilities
If you discover a security vulnerability within this script, please send an email to me. All security vulnerabilities will be promptly addressed.
## License
This script is open-sourced software licensed under the [MIT](LICENSE.md) and is distributed free of charge.
Commercial licensing (e.g. for projects that can’t use an open-source license) is available upon request.
## Author
Arthur Garegnyan
* Email: [email protected]
* GitHub: [https://github.com/ArthurGareginyan/](https://github.com/ArthurGareginyan/)
* Website: [http://www.arthurgareginyan.com](http://www.arthurgareginyan.com)
* Donation: [http://www.arthurgareginyan.com/donate.html](http://www.arthurgareginyan.com/donate.html)