Tag: rename

  • Snippet to remove caps and spaces from filename

    Remove caps and spaces from names in files in current directory with tr command. First step is parse the name of the file or directory and then rename it. for f in *; do file=$(echo $f | tr A-Z a-z | tr ‘ ‘ _) [ ! -f $file ] && mv “$f” $file done

  • How to rename a mysql database or table

    Here is a dirty script to rename a mysql database or table from command line. Dont for get to stop mysql service! cd /var/lib/mysql/ /etc/init.d/mysql stop # rename database… mv olddbname newdbname # …or table cd database/ mv oldname.frm newname.frm mv oldname.MYD newname.MYD mv oldname.MYI newname.MYI /etc/init.d/mysql start

  • how to batch file rename in bash shell

    This is a quick way of renaming a batch of files matching a reg exp in bash. ls foo*.jpg | awk ‘{print(“mv “$1” “$1)}’ | sed ‘s/foo/bar/2’ | /bin/sh