Search code examples
macoswindow

replace all files with same name


I have a file in multiple folder called PFSound.js I've updated it so I want to replace all PFSound.js files in those directories for the new one,

is there a way to do it in just one time?

Mac or windows is ok

Thanks!!


Solution

  • On Mac/Linux, you can do this:

    find . -type f -name "PFSound.js" -exec cp path/to/new/PFSound.js {} \;
    

    assuming you wish to do that from the current directory downwards and that the new PFSound.js is located somewhere else.

    That says.... find, starting at dot (the current directory) all things of type "file" with the name "PFSound.js", and for each one you find, execute the copy command and copy the new PFSound.js into the same place you just found an old one.