Loading ...
Sorry, an error occurred while loading the content.

Append File Name w/ Date

Expand Messages
  • Jolly Green Giant
    anyone got a batch file that will append the filemodification date to the filename for every file in a folder?
    Message 1 of 12 , May 6, 2003
    • 0 Attachment
      anyone got a batch file that will append the filemodification date to the
      filename for every file in a folder?
    • Michael Marquart
      What OS? What is the file date format? Do you also want time? On Tue, 06 May 2003 14:23:54 -0500, Jolly Green Giant
      Message 2 of 12 , May 6, 2003
      • 0 Attachment
        What OS? What is the file date format? Do you also want time?

        On Tue, 06 May 2003 14:23:54 -0500, Jolly Green Giant
        <jollygreengiant@...> wrote:

        >anyone got a batch file that will append the filemodification date to the
        >filename for every file in a folder?
      • Jolly Green Giant
        Windows 2000 File date format: pretty much anything. YYYYMMDD would be fine. Time is not necessary, thanks. thanks for the response! David
        Message 3 of 12 , May 7, 2003
        • 0 Attachment
          Windows 2000

          File date format: pretty much anything. YYYYMMDD would be fine.

          Time is not necessary, thanks.

          thanks for the response!
          David

          __________/ Michael Marquart \__________
          >What OS? What is the file date format? Do you also want time?
          >
          >On Tue, 06 May 2003 14:23:54 -0500, Jolly Green Giant
          ><jollygreengiant@...> wrote:
          >
          > >anyone got a batch file that will append the filemodification date to
          > the
          > >filename for every file in a folder?
        • Michael Marquart
          @echo off for /f tokens=2-4 delims=/- %%a in ( %date% ) do set DAY=%%c%%b%%a echo %day% ... for /f delims= %%a in ( dir *.* /b ) do ren %%a
          Message 4 of 12 , May 7, 2003
          • 0 Attachment
            @echo off
            for /f "tokens=2-4 delims=/- " %%a in ("%date%") do set DAY=%%c%%b%%a
            echo %day%
            :: gives the output format 20020821
            :: when the DATE /T output is "Wed 21/08/2002"

            for /f "delims=" %%a in ('dir *.* /b') do ren "%%a" "%%~na.%day%%%~xa"
            set day=


            Not tested, so make sure you test it on a dummy folder first.

            --
            Regards,
            Michael



            On Wed, 07 May 2003 10:40:37 -0500, Jolly Green Giant
            <jollygreengiant@...> wrote:

            >Windows 2000
            >
            >File date format: pretty much anything. YYYYMMDD would be fine.
            >
            >Time is not necessary, thanks.
            >
            >thanks for the response!
            >David
            >
            >__________/ Michael Marquart \__________
            >>What OS? What is the file date format? Do you also want time?
            >>
            >>On Tue, 06 May 2003 14:23:54 -0500, Jolly Green Giant
            >><jollygreengiant@...> wrote:
            >>
            >> >anyone got a batch file that will append the filemodification date to
            >> the
            >> >filename for every file in a folder?
          • Michael Marquart
            Hold on that - it s using the current date. d oh! On Thu, 08 May 2003 02:07:52 +1000, Michael Marquart
            Message 5 of 12 , May 7, 2003
            • 0 Attachment
              Hold on that - it's using the current date. d'oh!

              On Thu, 08 May 2003 02:07:52 +1000, Michael Marquart
              <micm@...> wrote:

              >
              >@echo off
              >for /f "tokens=2-4 delims=/- " %%a in ("%date%") do set DAY=%%c%%b%%a
              >echo %day%
              >:: gives the output format 20020821
              >:: when the DATE /T output is "Wed 21/08/2002"
              >
              >for /f "delims=" %%a in ('dir *.* /b') do ren "%%a" "%%~na.%day%%%~xa"
              >set day=
              >
              >
              >Not tested, so make sure you test it on a dummy folder first.
            • Michael Marquart
              Try this on some files in a test folder. I don t have a W2K box handy to test it on. ATM it doesn t perform the rename, it just prints the command on the
              Message 6 of 12 , May 7, 2003
              • 0 Attachment
                Try this on some files in a test folder. I don't have a W2K box handy to
                test it on. ATM it doesn't perform the rename, it just prints the command
                on the screen. Remove the "echo " if it seems to be doing as it should.

                I'd appreciate some feedback on this, if it works or not. Thanks.


                @echo off
                :: Renames all files in the current folder to filename-yymmdd.ext
                :: when DIR date format is in mmddyy
                :: Untested
                for /f "delims=" %%a in ('dir *.* /b') do (
                for /f "tokens=1-3 delims=/- " %%b in ("%%~ta") do (
                echo ren "%%a" "%%~na-%%c%%a%%b%%~xa"
                )
                )


                --
                Regards,
                Michael



                On Wed, 07 May 2003 10:40:37 -0500, Jolly Green Giant
                <jollygreengiant@...> wrote:

                >Windows 2000
                >
                >File date format: pretty much anything. YYYYMMDD would be fine.
                >
                >Time is not necessary, thanks.
                >
                >thanks for the response!
                >David
                >
                >__________/ Michael Marquart \__________
                >>What OS? What is the file date format? Do you also want time?
                >>
                >>On Tue, 06 May 2003 14:23:54 -0500, Jolly Green Giant
                >><jollygreengiant@...> wrote:
                >>
                >> >anyone got a batch file that will append the filemodification date to
                >> the
                >> >filename for every file in a folder?
              • Michael Marquart
                I did note one error - the terms in the target portion of the rename command should be correct now. @echo off ... for /f delims= %%a in ( dir *.* /b ) do (
                Message 7 of 12 , May 7, 2003
                • 0 Attachment
                  I did note one error - the terms in the target portion of the rename
                  command should be correct now.

                  @echo off
                  :: Renames all files in the current folder to filename-yymmdd.ext
                  :: when DIR date format is in mmddyy
                  :: Untested
                  for /f "delims=" %%a in ('dir *.* /b') do (
                  for /f "tokens=1-3 delims=/- " %%b in ("%%~ta") do (
                  echo ren "%%a" "%%~na-%%d%%b%%c%%~xa"
                  )
                  )

                  On Thu, 08 May 2003 02:22:46 +1000, Michael Marquart
                  <micm@...> wrote:

                  >
                  >Try this on some files in a test folder. I don't have a W2K box handy to
                  >test it on. ATM it doesn't perform the rename, it just prints the command
                  >on the screen. Remove the "echo " if it seems to be doing as it should.
                  >
                  >I'd appreciate some feedback on this, if it works or not. Thanks.
                  >
                  >
                  >@echo off
                  >:: Renames all files in the current folder to filename-yymmdd.ext
                  >:: when DIR date format is in mmddyy
                  >:: Untested
                  >for /f "delims=" %%a in ('dir *.* /b') do (
                  >for /f "tokens=1-3 delims=/- " %%b in ("%%~ta") do (
                  >echo ren "%%a" "%%~na-%%c%%a%%b%%~xa"
                  >)
                  >)
                • Jolly Green Giant
                  Works great!!! Thanks! So, for my own education, what I m seeing is that we are not able to get into any file attributes that are not displayable on the
                  Message 8 of 12 , May 7, 2003
                  • 0 Attachment
                    Works great!!! Thanks!

                    So, for my own education, what I'm seeing is that we are not able to get
                    into any file attributes that are not displayable on the screen, eh? We
                    basically read in a directory listing, and then parse that, right?

                    __________/ Michael Marquart \__________


                    >I did note one error - the terms in the target portion of the rename
                    >command should be correct now.
                    >
                    >@echo off
                    >:: Renames all files in the current folder to filename-yymmdd.ext
                    >:: when DIR date format is in mmddyy
                    >:: Untested
                    >for /f "delims=" %%a in ('dir *.* /b') do (
                    >for /f "tokens=1-3 delims=/- " %%b in ("%%~ta") do (
                    >echo ren "%%a" "%%~na-%%d%%b%%c%%~xa"
                    >)
                    >)
                    >
                    >On Thu, 08 May 2003 02:22:46 +1000, Michael Marquart
                    ><micm@...> wrote:
                    >
                    > >
                    > >Try this on some files in a test folder. I don't have a W2K box handy
                    > to
                    > >test it on. ATM it doesn't perform the rename, it just prints the
                    > command
                    > >on the screen. Remove the "echo " if it seems to be doing as it should.
                    > >
                    > >I'd appreciate some feedback on this, if it works or not. Thanks.
                    > >
                    > >
                    > >@echo off
                    > >:: Renames all files in the current folder to filename-yymmdd.ext
                    > >:: when DIR date format is in mmddyy
                    > >:: Untested
                    > >for /f "delims=" %%a in ('dir *.* /b') do (
                    > >for /f "tokens=1-3 delims=/- " %%b in ("%%~ta") do (
                    > >echo ren "%%a" "%%~na-%%c%%a%%b%%~xa"
                    > >)
                    > >)
                    >
                    >
                    >
                    >Yahoo! Groups Sponsor
                    >
                    >
                    >
                    >
                    >To Post a message, send it to: batchworld@...
                    >
                    >To Unsubscribe, send a blank message to:
                    >batchworld-unsubscribe@...
                    >
                    >Your use of Yahoo! Groups is subject to the
                    ><http://docs.yahoo.com/info/terms/>Yahoo! Terms of Service.
                  • Michael Marquart
                    If you have a look toward the bottom of the FOR /? help output you will see all the variables that you can use, similar to the %~tX variable that provides the
                    Message 9 of 12 , May 7, 2003
                    • 0 Attachment
                      If you have a look toward the bottom of the
                      FOR /?
                      help output you will see all the variables that you can use, similar to
                      the %~tX variable that provides the file date/time, and which is the
                      variable that is parsed in this batch file.

                      A dir /b is used to get the list of filenames to be processed.

                      Thanks for the feedback.

                      --
                      Regards,
                      Michael



                      On Wed, 07 May 2003 13:36:43 -0500, Jolly Green Giant
                      <jollygreengiant@...> wrote:

                      >Works great!!! Thanks!
                      >
                      >So, for my own education, what I'm seeing is that we are not able to get
                      >into any file attributes that are not displayable on the screen, eh? We
                      >basically read in a directory listing, and then parse that, right?
                      >
                      >__________/ Michael Marquart \__________
                      >
                      >
                      >>I did note one error - the terms in the target portion of the rename
                      >>command should be correct now.
                      >>
                      >>@echo off
                      >>:: Renames all files in the current folder to filename-yymmdd.ext
                      >>:: when DIR date format is in mmddyy
                      >>:: Untested
                      >>for /f "delims=" %%a in ('dir *.* /b') do (
                      >>for /f "tokens=1-3 delims=/- " %%b in ("%%~ta") do (
                      >>echo ren "%%a" "%%~na-%%d%%b%%c%%~xa"
                      >>)
                      >>)
                      >>
                    Your message has been successfully submitted and would be delivered to recipients shortly.