Batch remove whitespace in all the files in directory and replace with a dash "-"


/ Published in: Bash

Add this to your .profile or .bash_rc file, source the file, navigate to the directory and call "rm_whitespace"

Based on: http://snipplr.com/view/4468/batch-rename-files-in-directory/


Copy this code and paste it in your HTML
  1. alias rm_whitespace="for F in * ; do NF=\`echo \$F | perl -lne \"s/ /-/g; s/\_/-/g; s/[,']//g; s/[-]+/-/g; print\"\` ; mv \"\$F\" \"\$NF\" ; done"

URL: http://snipplr.com/view/4468/batch-rename-files-in-directory/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.