formulafo
asked on
Append to log in batch script
Hi,
I'm trying to make a this script and it is working(deleting the folders/files I want), the issue is that the logging append function on line 8 after "%%a" does not seem to want to append to the log file. The other lines that are appended to log file are working fine.
Does anyone have any suggestions/solutions on how I could solve this ?
Thanks for your time/help in advance :)
I'm trying to make a this script and it is working(deleting the folders/files I want), the issue is that the logging append function on line 8 after "%%a" does not seem to want to append to the log file. The other lines that are appended to log file are working fine.
Does anyone have any suggestions/solutions on how I could solve this ?
Thanks for your time/help in advance :)
:: --- BATCH SCRIPT START ---
@ECHO OFF
::---------------------------------------------------------------------------
SET LogFileName=del_folders_with_content.log
SET DIR_Path=E:\IMG00*.*
::---------------------------------------------------------------------------
SETLOCAL
for /f "tokens=*" %%a in ('dir /s /b /ad "%DIR_Path%" 2^>NUL') do rd /s /q "%%a" >> %~dp0%LogFileName%
ECHO.---------------------------------------------------------------------- >> %~dp0%LogFileName%
ECHO Date/Time: %DATE% - %TIME% >> %~dp0%LogFileName%
ECHO.---------------------------------------------------------------------- >> %~dp0%LogFileName%
ENDLOCAL
EXIT
:: --- BATCH SCRIPT END ---
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I just changed it to use brackets and kept the 2^>NUL instead of con. So it looks like this now:
Open in new window