borrowed foxidrive's vb/batch code from below
http://www.dostips.com/forum/viewtopic.php?f=3&t=3250
and went through it and refer a few example scripts and came with a 3 line solution
Code: Select all
Set oFSO = CreateObject("Scripting.FileSystemObject")
n = oFSO.GetFile(WScript.Arguments(0)).DateLastModified
Wscript.StdOut.Write CStr(Year(n)) + Right(100+Month(n),2) + Right(100+Day(n),2) + "-" + Right(100+Hour(n),2) + Right(100+Minute(n),2) + Right(100+Second(n),2) + " "
used Wscript.StdOut.Write example from stackoverflow so there would be no CRLF left behind. since there is no CRLF, i could than use the existing old script to write on the same line before echo to new line.
so on using batch this works
Code: Select all
D:\>cscript /nologo vbsfiledate.vbs "d:\test test.txt"
20130720-011206
wanted to make a no temporary file so i could learn from this.
borrowed dave's jeval.bat from stackoverflow(it is the shortest compare to repl and antonio's findrepl)
http://stackoverflow.com/questions/4495576/echo-e-equivalent-in-windows
tried to look up from mdsn of different between jscript and do but still getting some errors. What i have now is this
Code: Select all
@if (@X)==(@Y) @end /* harmless hybrid line that begins a JScrpt comment
::: Batch part ::::
@echo off
cscript //nologo //e:JScript "%~f0" %*
exit /b
*** JScript part ***/
var fso, n;
fso = new ActiveXObject("Scripting.FileSystemObject");
n = fso.GetFile(WScript.arguments(0)).DateLastModified;))
Wscript.StdOut.Write(CStr(n.Year) + Right(100+n.Month,2) + Right(100+n.Day,2) + "-" + Right(100+n.Hour,2) + Right(100+n.Minute,2) + Right(100+n.Second,2) + " ");
and the error below
Code: Select all
D:\>jdt "d:\test.txt"
D:\jdt.bat(11, 56) Microsoft JScript compilation error: Syntax error
needed some help on this. thanks.