Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Can someone provide batch code?  (Read 2785 times)

0 Members and 1 Guest are viewing this topic.

taylormade

    Topic Starter


    Greenhorn

    Can someone provide batch code?
    « on: February 21, 2009, 02:40:28 PM »
    I have a directory holding an MP3 file for each day. (ie: Feb09.mp3, Feb25.mp3 etc.)
    I need a batch file that will determine the current date....
       Grab the file for the current date....
         and FTP it to a location OVERWRITING (without confirmation) what is there.
      The destination file name will ALWAYS BE  rw.mp3
    I'll run this via the task scheduler each night.
    Can someone show me the Batch code that will do that?

    BatchFileCommand



      Hopeful
    • Thanked: 1
      Re: Can someone provide batch code?
      « Reply #1 on: February 21, 2009, 03:02:01 PM »
      Quote
      I need a batch file that will determine the current date....

      %date% is a system set variable that gives the date.
      οτη άβγαλτος μεταφ βαθμολογία

      devcom



        Apprentice

        Thanked: 37
        Re: Can someone provide batch code?
        « Reply #2 on: February 21, 2009, 04:15:29 PM »
        what is your output if you use
        Code: [Select]
        echo %date%
        in cmd ?
        Download: Choice.exe

        taylormade

          Topic Starter


          Greenhorn

          Re: Can someone provide batch code?
          « Reply #3 on: February 21, 2009, 04:56:06 PM »
          Sat 02/21/2009

          GuruGary



            Adviser
            Re: Can someone provide batch code?
            « Reply #4 on: February 22, 2009, 09:03:18 AM »
            Since you didn't specify, I assume the MP3 files are in the current directory, and the files should go to the default FTP directory.  You should be able to do something like this:
            Code: [Select]
            @echo off
            setlocal enabledelayedexpansion

            set FTPHost=myftphost.com
            set FTPUser=myusername
            set FTPPass=mypassword

            set MonthNum=%date:~4,2%
            set DayNum=%date:~7,2%
            set Loop=1
            for %%a in (Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec) do (
            if !MonthNum! equ !Loop! set Month=%%a
            set /a Loop+=1
            )
            set File=%Month%%DayNum%.mp3

            echo %FTPUser%>cmds.ftp
            echo %FTPPass%>>cmds.ftp
            echo bin>>cmds.ftp
            echo put %File% rw.mp3>>cmds.ftp
            echo quit>>cmds.ftp
            ftp -v -s:cmds.ftp %FTPHost%

            echo Done transferring %File%

            taylormade

              Topic Starter


              Greenhorn

              Re: Can someone provide batch code?
              « Reply #5 on: February 22, 2009, 10:16:30 AM »
              Thank you Gary...
              I appreciate your helping me.
              bob
               :D

              GuruGary



                Adviser
                Re: Can someone provide batch code?
                « Reply #6 on: February 22, 2009, 10:29:35 AM »
                No problem.

                BC_Programmer


                  Mastermind
                • Typing is no substitute for thinking.
                • Thanked: 1140
                  • Yes
                  • Yes
                  • BC-Programming.com
                • Certifications: List
                • Computer: Specs
                • Experience: Beginner
                • OS: Windows 11
                Re: Can someone provide batch code?
                « Reply #7 on: February 22, 2009, 10:29:51 AM »
                GuruGary is very helpful. Always posts a tested batch file in those threads that he can help with.
                I was trying to dereference Null Pointers before it was cool.