urgent:...read the first line of a file to use it in a bat-file - Programmer

This is a discussion on urgent:...read the first line of a file to use it in a bat-file - Programmer ; Hi! I have got one file to download every 10 min from a ftp-server. Unfortunately the name changes every time. I think about scheduling a bat-file which generates the ftp-script I need for the correct download. At the moment I ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: urgent:...read the first line of a file to use it in a bat-file

  1. urgent:...read the first line of a file to use it in a bat-file

    Hi!

    I have got one file to download every 10 min from a ftp-server.
    Unfortunately the name changes every time.

    I think about scheduling a bat-file which generates the ftp-script I need
    for the correct download.

    At the moment I stick at that point. (I know that this point would be no
    problem in any unix, but Ive got no real solution for windowsNT)

    I generate a file which contains the result of
    dir /b/o-g-d
    in that file I get the name of the youngerst file in the directory in the
    first row without any other information bevore.
    Now I want to pick that first row and use it generate the ftp-script I need.

    All those things should run in a bat-file, there is no vb on that maschine.

    Maybe you can help me
    thanks
    Petra



  2. Re: urgent:...read the first line of a file to use it in a bat-file

    Petra Hasenrath wrote:
    > Hi!
    >
    > I have got one file to download every 10 min from a ftp-server.
    > Unfortunately the name changes every time.
    >
    > I think about scheduling a bat-file which generates the ftp-script I need
    > for the correct download.
    >
    > At the moment I stick at that point. (I know that this point would be no
    > problem in any unix, but Ive got no real solution for windowsNT)
    >
    > I generate a file which contains the result of
    > dir /b/o-g-d
    > in that file I get the name of the youngerst file in the directory in the
    > first row without any other information bevore.
    > Now I want to pick that first row and use it generate the ftp-script I need.
    >
    > All those things should run in a bat-file, there is no vb on that maschine.
    >
    > Maybe you can help me
    > thanks
    > Petra
    >
    >


    Which version of NT are you using? NT4.0, Win2000, WinXP, or Win2003?

    If you are using anything newer than 4.0, you can use 'set /p' to read
    the first line of a file:

    SET /P var=
    Alternatively, change 'dir /b /o-g-d' to 'dir /b /a-d /od' and read the last
    line of the file.

    for /f "tokens=*" %%a in ('dir /b /a-d /od') do set var=%%a

    --
    Phil Robyn
    Univ. of California, Berkeley

    u n z i p m y a d d r e s s t o s e n d e - m a i l


  3. Re: urgent:...read the first line of a file to use it in a bat-file

    thanks
    it works

    "Phil Robyn" wrote in message
    news:bhtnab$333ph$1@ID-55492.news.uni-berlin.de...
    > Petra Hasenrath wrote:
    > > Hi!
    > >
    > > I have got one file to download every 10 min from a ftp-server.
    > > Unfortunately the name changes every time.
    > >
    > > I think about scheduling a bat-file which generates the ftp-script I

    need
    > > for the correct download.
    > >
    > > At the moment I stick at that point. (I know that this point would be no
    > > problem in any unix, but Ive got no real solution for windowsNT)
    > >
    > > I generate a file which contains the result of
    > > dir /b/o-g-d
    > > in that file I get the name of the youngerst file in the directory in

    the
    > > first row without any other information bevore.
    > > Now I want to pick that first row and use it generate the ftp-script I

    need.
    > >
    > > All those things should run in a bat-file, there is no vb on that

    maschine.
    > >
    > > Maybe you can help me
    > > thanks
    > > Petra
    > >
    > >

    >
    > Which version of NT are you using? NT4.0, Win2000, WinXP, or Win2003?
    >
    > If you are using anything newer than 4.0, you can use 'set /p' to read
    > the first line of a file:
    >
    > SET /P var= >
    > Alternatively, change 'dir /b /o-g-d' to 'dir /b /a-d /od' and read the

    last
    > line of the file.
    >
    > for /f "tokens=*" %%a in ('dir /b /a-d /od') do set var=%%a
    >
    > --
    > Phil Robyn
    > Univ. of California, Berkeley
    >
    > u n z i p m y a d d r e s s t o s e n d e - m a i l
    >




+ Reply to Thread