0

I need to execute a short script that just renames a few files (mv).

The script is in about 50 folders, each folder is named and currently I'm executing them from the shell and moving to the next folder using:

bash rename && cd ../folder01

Then pressing up and changing the last digit(s).

Is there a way to execute the script in all folders in one line?

1 Answer 1

4

Sure, use a for loop:

for f in folder*; do (cd "$f" && bash rename) ; done
Sign up to request clarification or add additional context in comments.

2 Comments

you also don't neet to copy your script in each and every folder
@arashkordi I was copying it using 'echo folder{10..49} | xargs -n 1 cp script'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.