Bud in my Script please help

April 13, 2011 at 22:33:36
Specs: Windows 7
Hello every one, I am new in the scripting field and it seems quite interesting.
I have tried to write one small script that lists a file on a network paths to fetch its modification date information so that I can compare it.
It takes input as the file name.

Here is what I have made so far.

@echo off
set /p a=Enter File name:

set /p b=Enter directory name [premia/groupm]:

if %b%==premia goto premia
if %b%==groupm goto groupm

:premia
dir /X "\\server1\10g\premia\fmb\%a%">out.txt
dir "\\server2\d$\10g\premia\fmb\%a%">>out.txt
dir "\\server3\6i_10g\premia\fmb\%a%">>out.txt
goto END

:groupm
dir "\\server1\10g\GM\fmb\%a%">out.txt
dir "\\server2\d$\10g\GROUP MEDICAL\fmb\%a%">>out.txt
dir "\\server3\6i_10g\Group Medical\fmb\%a%">>out.txt

:END


This is the output:


Volume in drive \\server1\10g has no label.
Volume Serial Number is BC04-7BE5

Directory of \\server1\10g\premia\fmb

01/23/2011 02:53 PM 1,212,416 PT002.fmb
1 File(s) 1,212,416 bytes
0 Dir(s) 200,929,165,312 bytes free
Volume in drive \\server2\d$ is New Volume
Volume Serial Number is 80A2-E39F

Directory of \\server2\d$\10g\premia\fmb

01/31/2011 11:22 AM 2,772,992 PT002.fmb
1 File(s) 2,772,992 bytes
0 Dir(s) 141,632,602,112 bytes free
Volume in drive \\server3\6i_10g is Store
Volume Serial Number is A879-5CEE

Directory of \\server3\6i_10g\premia\fmb

01/23/2011 02:53 PM 1,212,416 PT002.fmb
1 File(s) 1,212,416 bytes
0 Dir(s) 28,995,825,664 bytes free


The output that I am looking for is something like this.

server1
4-01/23/2011 02:53 PM 1,212,416 PT002.fmb
server2
01/31/2011 11:22 AM 2,772,992 PT002.fmb
server3
01/23/2011 02:53 PM 1,212,416 PT002.fmb


So is there a way how can fetch only selected text. I have tried different DIR switches but they didn't seem to work.

Thanks.


See More: Bud in my Script please help

Report •


#1
April 14, 2011 at 08:11:33
@echo off
set /p a=Enter File name:

set /p b=Enter directory name [premia/groupm]:

if %b%==premia goto premia
if %b%==groupm goto groupm

:premia
call :GetDateTimeAndDisplay "\\server1\10g\premia\fmb\%a%" > out.txt
call :GetDateTimeAndDisplay "\\server2\d$\10g\premia\fmb\%a%" >> out.txt
call :GetDateTimeAndDisplay "\\server3\6i_10g\premia\fmb\%a%" >> out.txt
goto :EOF

:groupm
call :GetDateTimeAndDisplay "\\server1\10g\GM\fmb\%a%" > out.txt
call :GetDateTimeAndDisplay "\\server2\d$\10g\GROUP MEDICAL\fmb\%a%" >> out.txt
call :GetDateTimeAndDisplay "\\server3\6i_10g\Group Medical\fmb\%a%" >> out.txt
goto :EOF


:GetDateTimeAndDisplay
for /f "tokens=*" %%a in ('dir %1 /b') do (
  set T=%%~Ta
  set FileDay=!T:~3,2!
  set FileMonth=!T:~0,2!
  set FileYear=!T:~6,4!
  set Hour=!T:~11,2!
  set Minute=!T:~14,2!
  set Size=%%~za
  
  echo !FileMonth!/!FileDay!/!FileYear! !Hour!:!Minute! !Size! %%a
  )
goto :EOF

Not Tested.


Report •

#2
April 17, 2011 at 01:34:50
Thank u 4 ur reply but it didn't work at all .

Report •

#3
April 19, 2011 at 22:57:42
pls. some one help !


Report •

Related Solutions

#4
April 21, 2011 at 10:20:41
I don't have your files so I can't help with debugging the program. Just put in some echos in key places to you can see what the variable is set to and fix it. Here is where I got my information from hope it helps.

http://www.robvanderwoude.com/batte...


Report •


Ask Question