Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
Werna
- Posts: 2
- Joined: 10 Mar 2016 07:38
#1
Post
by Werna » 10 Mar 2016 07:45
Hello Experts,
I am struggeling with my bat-File which searches the string "created" in a File and then it should print it out.
It works but I really do not know how to delete the last symbols *)
 which are part of the string that is read from the file
Could anyone give me a hint?...please, please
Code: Select all
@ECHO OFF
setlocal enabledelayedexpansion
@REM File to be deleted
SET logfile="CreationDateOverview.txt"
@REM Try to delete the file only if it exists
IF EXIST %logfile% del /F %logfile%
ECHO ********************************************************************************************** >> %logfile%
FOR /F "tokens=1,4 delims=( " %%G IN ('FINDSTR /i "created" *.xml') DO (
SET str=%%H
ECHO %%G !str! >> %logfile%)
ECHO *************************************** >> %logfile%
CALL "notepad.exe" %logfile%
The Output is as follows:
FB_Toggle_pou_backup.xml: 2016-02-03T12:46:33.0288178
*)
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#2
Post
by foxidrive » 10 Mar 2016 11:55
This is the only change:
>> %logfile% ECHO %%G !str:~0,-7!Code: Select all
@ECHO OFF
setlocal enabledelayedexpansion
@REM File to be deleted
SET logfile="CreationDateOverview.txt"
@REM Try to delete the file only if it exists
IF EXIST %logfile% del /F %logfile%
ECHO ********************************************************************************************** >> %logfile%
FOR /F "tokens=1,4 delims=( " %%G IN ('FINDSTR /i "created" *.xml') DO (
SET str=%%H
>> %logfile% ECHO %%G !str:~0,-7!)
ECHO *************************************** >> %logfile%
CALL "notepad.exe" %logfile%
-
Werna
- Posts: 2
- Joined: 10 Mar 2016 07:38
#3
Post
by Werna » 11 Mar 2016 01:26
Thanks a lot......works perfectly