macOS Batch Rename Files Using Bash
If you want to batch rename some files you can use a little Perl utility renamed that uses pattern matching to rename files.
It comes with some systems but not with macos. You can install it using brew.
$ brew install rename
First do a dry run:
$ rename 's/entities\.//' *.json -n
'entity.create.json' would be renamed to 'create.json'
'entity.create.res.json' would be renamed to 'create.res.json'
'entity.delete.json' would be renamed to 'delete.json'
'entity.delete.read.res.json' would be renamed to 'delete.read.res.json'
'entity.delete.res.json' would be renamed to 'delete.res.json'
'entity.findEntityByKey.json' would be renamed to 'findEntityByKey.json'
'entity.read.json' would be renamed to 'read.json'
'entity.read.res.json' would be renamed to 'read.res.json'
'entity.update.json' would be renamed to 'update.json'
'entity.update.read.res.json' would be renamed to 'update.read.res.json'
'entity.update.res.json' would be renamed to 'update.res.json'
'entity.upsertEntityByKey.json' would be renamed to 'upsertEntityByKey.json'
Now you can run it for real, without the -n
flag:
$ rename 's/entities\.//' *.json
Output:
renamed: entity.create.json -> create.json
renamed: entity.create.res.json -> create.res.json
renamed: entity.delete.json -> delete.json
renamed: entity.delete.read.res.json -> delete.read.res.json
renamed: entity.delete.res.json -> delete.res.json
renamed: entity.findEntityByKey.json -> findEntityByKey.json
renamed: entity.read.json -> read.json
renamed: entity.read.res.json -> read.res.json
renamed: entity.update.json -> update.json
renamed: entity.update.read.res.json -> update.read.res.json
renamed: entity.update.res.json -> update.res.json
renamed: entity.upsertEntityByKey.json -> upsertEntityByKey.json