3 ms·
Wouldn't something like the following shell one-liner rename get you quite close? export javas=$(find . -regex '.*\.java$'); for old in $(grep -hrPo 'class
by patrec 4y ago
Wouldn't something like the following shell one-liner rename get you quite close?
export javas=$(find . -regex '.*\.java$'); for old in $(grep -hrPo 'class (?!Kt)\K[A-Z]\w+'); do echo $old; sed -i "s/\<$old\>/Kt$old/g" $javas; rename "s/^$old\$/Kt$old/" $javas; done
Untested, unoptimized, needs gnu grep and perl's rename utility (variously packaged as prename or rename-files, as opposed to the crappy linux-utils rename).
- patrec 4y agoHere you are, "gradle build" works with this cleaned up and faster version (and the diff looks plausible on first sight): javas=$(find . -regex '.*\.java$') sed -i -E "$(printf 's/\\<(%s)\\>/Kt\\1/g;' $(grep -hrPo '\b(class|interface|record|enum) (?!Kt)(?!List\b)(?!Entry\b)\K[A-Z]\w+'))" $(echo $javas); rename 's;\b(?!Kt)(\w+[.]java)$;Kt$1;' $(echo $javas) (The $(echo $javas) is so it works in both bash and zsh).