Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to overwrite files in a directory tree, recursively.

The ones I would like to overwrite match the filename "x_alpha*.png" and have a size exactly 456 bytes.

Is there any way to search for these recursively in a directory tree, and overwrite them with a reference file, for example "e:\mydir\good.png"

I am using Windows 7, but I have UnxUtils, so I can use those too.

What I am looking for is something like this, generated automatically:

copy /y e:\mydir\good.png e:\mydir\a\b\c\x_alpha0023.png
copy /y e:\mydir\good.png e:\mydir\e\f\g\x_alpha0045.png
copy /y e:\mydir\good.png e:\mydir\h\x_alpha0248.png
share|improve this question
up vote 0 down vote accepted

You can also do this in Power Shell since you are using Windows 7.

dir -recurse x_alpha*.png | where-object { $_.Length -eq 456 } | foreach-object { copy-item -force e:\mydir\good.png $_.FullName }
dir -recurse x_alpha*.png   (to see the results)
share|improve this answer

I do not know UnxUtils, but it can be done with cygwin with:

find /cygdrive/e/mydir/ -type f -name "x_alpha*.png" -size 456c -exec cp /cygdrive/e/mydir/good.png {} \;

You could probably extrapolate how to do this with UnxUtils.

Test it first by running the following before overwriting files:

find /cygdrive/e/mydir/ -type f -name "x_alpha*.png" -size 456c
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.