Recursively replace spaces with underscores in file and directory names
A safe solution to recursively replace spaces with underscores in file and directory names starting from the current directory.
tree . |-- a dir | `-- file with spaces.txt `-- b dir |-- another file with spaces.txt `-- yet another file with spaces.pdf
tree . |-- a_dir | `-- file_with_spaces.txt `-- b_dir |-- another_file_with_spaces.txt `-- yet_another_file_with_spaces.pdf
Give execute permissions:
chmod +x space_to_underscore.sh
Go to needed directory:
Run the space_to_underscore.sh which placed in user home directory:
This script is licensed under the GNU General Public License, version 3 (GPLv3) and is distributed free of charge.
Commercial licensing (e.g. for projects that can’t use an open-source license) is available upon request.