Vim question

Stephen Weeks tene at iodynamics.com
Tue Jan 13 21:39:39 MST 2009


Not long ago, Alec Shaw proclaimed...
> Every so often I have files with spaces in their names and I want to 
> rename them with underscores for the spaces.
> The way I have normally done the the renaming is by putting the output 
> of an ls into a file and editing the file in vim
> to make it into a script.
> I usually do ":g/.*/s//mv & &/ " and then hand editing the paces to 
> underscores in the third column.
> There has to be a better way.
> Is it possible to have vim do the substitution on the third column 
> without affecting the first column?
> Actually as I think about it maybe a bash or ksh (after years of use ksh 
> is still my preferred shell) script
> would be better.  Maybe a "for f in *; do mv $f $g; done" but how do I 
> get $g from $f with spaces substituted?
> 
> Thanks for any suggestions.
> Alec Shaw

I use the rename command for this.  The syntax is: rename FROM TO FILE...
So, for this example:

rename ' ' _ *



More information about the PLUG mailing list