Home > Back-end >  How to run command on subfolder of wildcard folders?
How to run command on subfolder of wildcard folders?

Time:04-01

Say I have this structure:

Some Folder 1/...
Some Folder 2/...
Adobe After Effects 2020/Scripts/
Adobe After Effects 2020/foo/
Adobe After Effects 2020/bar/
Adobe After Effects 2021/Scripts/
Adobe After Effects 2021/etc/
Adobe After Effects 2022/Scripts/
Another Folder/...

I want to change permissions on all the Scripts subfolders. I tried:

chmod -R o rw 'Adobe After Effects */Scripts'

But that doesn't work. Any way to accomplish this using wildcards?

CodePudding user response:

Wildcards are not expanded inside quotes, but you should be able to use this. Note that the * is now outside the quotes.

chmod -R o rw 'Adobe After Effects '*'/Scripts'

That will make the specified change on all files and directories with the 'Adobe After Effects' start and the Scripts subdirectory. I'm not sure that o rw is a good choice of permission, but you can fix that to suit yourself. I'd be more likely to use o r,o-w.

CodePudding user response:

Did you try ?

find -type d -name "Adobe After Effects *" -print0 | xargs -0 -I{.} find {.} -type d -name "Scripts" -exec chmod -R o rw {} \;

It uses nested find as explained in https://unix.stackexchange.com/a/18101/249463

  • Related