Posted By

licensetoil on 01/28/12


Tagged

whitespace unix remove files administration perl rename


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

sdudenhofer
Priestd09


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


 / Published in: Bash
 

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

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

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

  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"

Report this snippet  

You need to login to post a comment.