hi i have below code which is not work very well:
**************************
*
IF EXIST D:\ZfolderA\LOG.TXT COPY D:\ZfolderA\LOG.TXT D:\ZfolderB\%date:~4,2%%da
te:~7,2%%d
ate:~10,4%
LOG%time:~
0,2%%time:
~3,2%.TXT
IF EXIST D:\ZfolderA\EIB.TXT COPY D:\ZfolderA\EIB.TXT D:\ZfolderB\%date:~4,2%%da
te:~7,2%%d
ate:~10,4%
EIB%time:~
0,2%%time:
~3,2%.TXT
rem del /q "D:\ZfolderA\*.TXT"
@echo off
set loglocation=D:\ZfolderB\DE
LOLDFILE.L
OG
set olderthan=180
set source=D:\ZfolderB
set extension=TXT
if not exist D:\ZfolderB\DELOLDFILE.LOG
@copy/y nul D:\ZfolderB\DELOLDFILE.LOG
1>nul 2>nul
echo Deleting files of 0 kb with the file extension *.%extension% located at %source%.
echo Deleting files of 0 kb with the file extension *.%extension% located at %source%. >> %loglocation%
@echo off & setlocal enableextensions
setlocal
set SourcePathA=D:\ZfolderB
for %%f in (%SourcePathA%\*.TXT) do (
if %%~zf EQU 0 del "%%~ff" & echo %SourcePathA%\@FILE deleted. >> %loglocation%
REM***************
REM here it is not writing the filenames in the logfile. i get "D:\ZfolderB\@FILE deleted."
REM***************
)
endlocal
echo Deleting files older than %olderthan% days with the file extension *.%extension% located at %source%.
echo Deleting files older than %olderthan% days with the file extension *.%extension% located at %source%. >> %loglocation%
cd %source%
echo List of files to be removed: >> %loglocation%
echo List of files to be removed:
FORFILES -p%source% -m*.%extension% -c "CMD /C Echo @FILE" -d-%olderthan%
FORFILES -p%source% -m*.%extension% -c "CMD /C Echo @FILE" -d-%olderthan% >> %loglocation%
REM***************
REM here i get "List of files to be removed:"
REM "can't execute (error 2)"
REM "can't execute (error 2)"
REM "can't execute (error 2)"
REM***************
REM***************
REM these are the 2 errors i receive till here which is where i debuged till now
REM***************
pause
echo Starting delete...
echo Starting delete... >> %loglocation%
date /t >> %loglocation%
time /t >> %loglocation%
FORFILES -p %source% /d -%olderthan% -m *.%extension% -c "CMD /C del %source%\@FILE /q & echo %source%\@FILE deleted." >> %loglocation%
echo Log file located at %loglocation%
echo Delete finished...
echo Delete finished... >> %loglocation%
date /t >> %loglocation%
time /t >> %loglocation%
maybe i have some syntax errors? please some help.
Start Free Trial