2

I'm trying to to execute a script, which uses the command rename.

When I execute it, I get a message rename: command not found. Any ideas?

if [[ -z '$3' ]]; then
    shopt -s dotglob
    rename "$EXPRESSION" ./*
else
    rename "$EXPRESSION" "$3"
fi
  • 3
    sounds to me like rename isn't an installed function anywhere. Or it's not configured in your script properly. As-is, that script doesn't define a functoin called "rename". Further, rename can be a perl package extension for File::Rename and provides a 'newer' interface / command line tool for rename functions – Thomas Ward Nov 24 '18 at 21:28
  • 1
    Did you try installing it with sudo apt install rename before running the script? – dessert Nov 24 '18 at 22:15
2

I just had to install the rename package.

sudo apt install rename
  • 1
    For the sake of completeness, could you edit to add how you installed it? – wjandrea Nov 24 '18 at 22:36
  • @wjandrea edited. – paweljvn Nov 24 '18 at 22:38
  • Great. Though it's not a function; it's a file. – wjandrea Nov 24 '18 at 22:40
  • @wjandrea I will remember it for the next time. Sorry and thank you. – paweljvn Nov 24 '18 at 22:49
  • 2
    Perl rename was installed by default up until, I think 17.04. So earlier posts and guides might assume it was present and not mention this step. On other Linux systems, there is another rename program which works differently also. – Zanna Dec 15 '18 at 9:19

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.