I have a folder on my drive, which I regulary clean. It has only txt files with sql logs. How can I write batch script which is going to clean it when I run it ? What I mean is, I do not want to go to drive, look for the folder, etc. Just have a shortcut on my screen, which is going to turn batch script on.
I tried to write it myslef, and modify it a bit, but its not working.
`@echo off set "search_folder=C:\path\to\folder" for /f "delims=" %%f in ('dir /b /s /a-d "%search_folder%\*.txt"') do ( type "%%f" | findstr /v /r "^[ ]*$" > temp.txt move /y temp.txt "%%f" )` it does not delete anything
del /A /F /Q "C:\path\to\folder\*.txt". There is no batch file needed at all. A shortcut file –.lnkfile as present on your desktop and in Window Start menu – with property Target being configured as%SystemRoot%\System32\cmd.exe /D /C del /A /F /Q "C:\path\to\folder\*.txt"is absolutely enough and makes it possible to configure property Run with Minimized. See also my comments on this question if a scheduled task should be used for this purpose.