Artificial intelligent assistant

Bulk renaming of camelcase files to include spaces I'm attempting a batch rename of camelcase-named files to include spaces between adjacent upper and lower case leters. I'm using Mac OS so the utils I'm using are the BSD-variant. For example: 250 - ErosPhiliaAgape.mp3 => 250 - Eros Philia Agape.mp3 I'm trying to `find` the relevant files and pipe them to `mv` which runs `sed` in a subshell, using this command: find . -name "*[a-z][A-Z]*" -print0 | xargs -0 -I {} mv {} "$(sed -E 's/([a-z])([A-Z])/\1 \2/g')" Individually, these commands work fine: `find` pulls up the correct files and `sed` renames it correctly, but when I combine them with xargs, nothing happens. What do I need to change to make this work?

The problem is that the `$(...)` sub-shell in your command is evaluated at the time you run the command, and not evaluated by `xargs` for each file. You could use `find`'s `-exec` instead to evaluate commands for each file in a `sh`, and also replace the quoting appropriately:


find . -name "*[a-z][A-Z]*" -type f -exec sh -c 'echo mv -v "{}" "$(echo "{}" | sed -E "s/([a-z])([A-Z])/\1 \2/g")"' \;


If the output of this looks good, drop the `echo` in `echo mv`. Note that due to `echo | sed`, this won't work with filenames with embedded `\
`. (But that was an already existing limitation in your own attempt, so I hope that's acceptable.)

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 8a923cb23756acde0f80ac22d98055ae