How to find any file or folder with a trailing space in it’s name, and delete the trailing space

Windows does not know how to handle files or folders whos name ends in a space. Usually Windows won’t allow you to delete these files, and other bizarre behavior.

This is a simple bash command to fix that.

 

find . -name '* ' -exec sh -c 'x="{}"; mv "$x" "${x%?}"' \;

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.