Reputation: 15
I want to replace a specific file eg. file.js which is located in different folderstructures but always in the same folder named "core" by another file with the same name.
Example: copy "file.js" to all "core" folders which are in different subfolders of a folder
Example:
from:
x1 / file.js
to:
x / a / a1 / a3 / core /file.js
x / b / b1 / core / file.js
I tried a solution in automator on osx, but I didn't manage to store a filepath of the core folders or to copy the file to a path variable.
Does anyone know a solution?
shell script or automator or any other automated solution
Upvotes: 0
Views: 725
Reputation: 207455
This should do it as a bash
script but test it on a copy of temporary data first:
find . -name core -type d -execdir bash -c 'cd core && [ -f file.js ] && cp SOMENEWFILE .' \;
Replace the cp SOMENEWFILE .
with pwd
to test and see which directories it would copy to.
Upvotes: 1