Solved TO : M2. Script cut 190 chars is not working properly.

July 23, 2012 at 00:52:34
Specs: Windows XP
Hi M2,
I have tested your script. it works properly but when I put it on windows scheduler (runs every 5 minutes) it become error because when the script didn't find any .txt file to be cut 190 chars, it will create .txt. Could you please check to change the script to not create a .txt file if the script didnt find any file to be cut.
Below is script i modified from you script. I add several rows to change the file to outfile+date+time+.txt.
Please your help to review the script.
Many thanks for your help

@echo off & setLocal enableDELAYedeXpansioN
set N=
for /f "tokens=* delims= " %%a in (PF.txt) do (
set /a N+=1
if !N! lss 3 set S=!S!%%a
)
> 1.txt echo.!S:~190!

for /f "tokens=* skip=2 delims= " %%a in (PF.txt) do (
echo.%%a
) >> outfile.txt

for /f "tokens=* skip=2 delims= " %%a in (outfile.txt) do (
if >10 equ %%~zF echo del "%%a"
)

set curndate=%date%%time%
set myvar3=%curndate:~4,2%
set myvar2=%curndate:~7,2%
set myvar1=%curndate:~10,4%
set myvar4=%curndate:~14,2%
set myvar5=%curndate:~17,2%
set myvar6=%curndate:~20,2%
ren outfile.txt outfile%myvar1%%myvar3%%myvar2%%myvar4%%myvar5%%myvar6%.txt
goto :eof


See More: TO : M2. Script cut 190 chars is not working properly.

Report •


#1
July 23, 2012 at 02:27:03
✔ Best Answer
To me, scheduler has always been a pain in the butt. And AT ain't much better.


====================================
Life is too important to be taken seriously.

M2


Report •

#2
July 23, 2012 at 02:54:34
to : M2,
when the script didnt find any file, it will generate outfile.txt with content "~190".
What to stop generate .txt file if not meet PF.txt?
if put your script (in other topic) :
for /f "tokens=* skip=2 delims= " %%a in (outfile.txt) do (
if >10 equ %%~zF echo del "%%a"
)
but the outfile.txt still not removed.
What's wrong?
many thanks

Report •

Related Solutions


Ask Question