Unix Script (Bourne) to Remove Spaces in File Names

Posted on December 26, 2012 by quashnsa

#!/bin/sh
find . -name '* *' | while read file;
do
target=`echo "$file" | sed "s/ /_/g"`;
if [ -f $target ]
then
echo "File Exists: $target";
else
echo "Renaming '$file' to '$target'";
mv "$file" "$target";
fi
done;

« Prev itemNext item »

Comments

No comments yet. You can be the first!

Leave comment

This item is closed, it's not possible to add new comments to it or to vote on it