20121213 bulk rename files in bash - plembo/onemoretech GitHub Wiki

title: Bulk rename files in bash link: https://onemoretech.wordpress.com/2012/12/13/bulk-rename-files-in-bash/ author: lembobro description: post_id: 3791 created: 2012/12/13 12:55:50 created_gmt: 2012/12/13 16:55:50 comment_status: closed post_name: bulk-rename-files-in-bash status: publish post_type: post

Bulk rename files in bash

Needed to rename a bunch of files and didn't want to write a program. Bash one-liner below did the job. I had a VMware guest I wanted to clone. Copied the whole guest directory to another but then had to rename all the files within. Here's my command syntax for that:

ls linuxc* | awk '{print("mv "$1" "$1)}' | sed 's/linuxc/linuxd/2' | /bin/sh

Found this here. Yes, it appears that Mac users can indeed invent useful one-liners in bash -- something I at least am thankful for.

Copyright 2004-2019 Phil Lembo