0

I just moved fro mDebian to macOS after my laptop crashed. Luckily I was abele to salvage my .zshrc with my aliases, however, m two aliases that use "find" don't seem to work in macOS and I am not quite sure what the difference is.

The first command is supposed to move all files fro msubdirectories to the current directory and it worked flawlessly on debian:

alias mup='find -type f -exec mv {} . \;'

On macOS however I get a "find: illegal option -- t"

Similarly, to change the file ending from JPG to jpg I used

alias jprn="find -name '*.JPG' -exec rename "s/.JPG/.jpg/g" \{\} \;"

which results in another "find: illegal option -- n"

Unfortunately, the error is rather mysterious, so I don't even know where to start looking for a resolution, as all the handles seem to be correct based on man.

Any info or pointer would be much appreciated!

Thanks

1

for mup, find needs a path argument:

alias mup='find . -type f -exec mv {} . \;'

for jprn, find needs a path argument. Also, there's no rename command in macOS (you can install it with Homebrew though). This is the best I could come up with at the moment:

alias jprn='find . -name "*.JPG" -print | while read -r f; do mv "$f" "${f/%JPG/jpg}"; done'

${f/%JPG/jpg} substitutes $f ending in JPG with jpg, see the last part of section "Parameter Expansion" in man zshexpn.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.