I am using the following script to generate a checksum file for hundreds of files in several subdiretories. The files are generated as expected in those directories. However I cannot figure out how to tell the files to be written to a different location that with their original source file. example write the files to c:\checksum\projects.
I know this will be a simple question/answer for someone that uses powershell daily.
The previous example uses a foreach statement construct which will load everything into memory. It’s very fast, but if you have a large amount of files this could be an issue. The following example changes it to utilize the pipeline.
The previous example uses a foreach statement construct which will load everything into memory. It’s very fast, but if you have a large amount of files this could be an issue. The following example changes it to utilize the pipeline.
It’s not pretty, and I’m sure there are better ways to do it, but this works assuming the targets are on the C: drive. If not, replace C: with the appropriate letter.
FANTASTIC! The last example works as I needed. I really appreciate it.
One last question. Is there a way to set the date/time of the newly created checksum file to the same date/time of the original file it was created from?
One least question. I have everything figured out except for one item. Can you provide me an example of how to skip writing the .checksum file if it already exists?
You don’t need to check that the file matches a specific criteria or is a certain age? If not, then we can test-path like we did for the folder and only if it’s not found would we calculate the hash and write it.