2

I have a folder topdir which contains subfolders like %foo or %bar but also foobar.

Any % signs at the first char should be removed, so that %foo gets renamed to foo. There's no need for recursive renaming, only folders inside topdir should be renamed.

How can this be achieved?

1 Answer 1

5

Go to the directory, rename each directory in turn, but only if the destination doesn't already exist

cd topdir &&
  for src in %*
  do
      dst="${src#%}"
      [ -d "$src" ] && [ ! -e "$dst" ] && mv -- "$src" "$dst"
  done
0

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.