Skip to content

Instantly share code, notes, and snippets.

@sahildev001
Last active March 29, 2023 13:04
Show Gist options
  • Save sahildev001/0467296537fd843c29372a7590bfbc79 to your computer and use it in GitHub Desktop.
Save sahildev001/0467296537fd843c29372a7590bfbc79 to your computer and use it in GitHub Desktop.
Shell script for remove whitespace from file name
find . -depth -name '* *' | while read fname
do
new_fname=`echo $fname | tr " " "_"`
if [ -e $new_fname ]
then
echo "File $new_fname already exists. Not replacing $fname"
else
echo "Creating new file $new_fname to replace $fname"
mv "$fname" $new_fname
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment