View Single Post
  #3   (View Single Post)  
Old 13th August 2008
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Tcpdump Spy
 
Join Date: Apr 2008
Location: New Zealand
Posts: 2,201
Default

I would do it like this ...

Code:
#!/bin/sh

RenameFile()
{
  cd ${1}

  for f in *; do
    nf=$(echo "${f}" | tr ' ' _)

    if [ "${f}" != "${nf}" ]; then
      mv -f "${f}" "${nf}"
    fi

    if [ -d "${nf}" ]; then
      RenameFile "${nf}"
    fi
  done

  cd -
}

find . -name "*.jpg" -or -name Thumbs.db -or -name "*.ini" -delete
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;

RenameFile .
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote