Quantcast
Channel: Bulk renaming of camelcase files to include spaces - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 4

Answer by janos for Bulk renaming of camelcase files to include spaces

$
0
0

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 \n. (But that was an already existing limitation in your own attempt, so I hope that's acceptable.)


Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>