Home > Software design >  Windows Batch Echo Output to LOG Results in Frequent "The process cannot access the file becaus
Windows Batch Echo Output to LOG Results in Frequent "The process cannot access the file becaus

Time:02-16

I have a basic Windows batch script comparing hashes of two files spitting out hashes that don't exist in both txt files.

First it generates a clean file without headers and ignores misc files like Thumbs.db or desktop.ini and stores them in "#_file1_clean.txt", "#_file2_clean.txt". This works great.

Then I use that clean file to generate a log file containing ONLY the hashes. This is where the issue lies, simply from ECHO %%b>>logfile.txt statement, it occasionally throws a "The process cannot access the file because it is being used by another process." error.

Then I use the findstr command to output lines that don't match. This works fine.

Here's the code:

@ECHO OFF
SET "batchpath=%~dp0"
CD /D "           
  • Related