[thelist] bulk rename on Mac

Phil Turmel philip at turmel.org
Tue Nov 23 22:05:31 CST 2010


On 11/23/2010 10:57 PM, Phil Turmel wrote:
> 
> Good Lord!  sed?  Does the MacOS shell not include the expansion operators % or %% ?
> 
> If it does support them, try:
> 
> for arg in *.asp ; do mv $arg ${arg%.asp}.php ; done
> 
> If it doesn't support them, please accept my condolences.
> 
> Phil

On further note:  if your filenames might have spaces in them, additional double-quotes will protect them, like so:

for arg in *.asp ; do mv "$arg" "${arg%.asp}.php" ; done

Phil


More information about the thelist mailing list