Remove Time Element From File Creation Date

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Cap'nKirk
Posts: 4
Joined: 22 Jan 2014 03:40

Remove Time Element From File Creation Date

#1 Post by Cap'nKirk » 22 Jan 2014 03:49

Hi,

I have a batch file that outputs a list of files in a directory along with their creation and modification dates.

Unfortunately the creation date also includes the time which for my needs is not necessary and I am trying to remove this element but without luck.

The variable for the Creation Date is:

%%~ta

Unfortunately I am currently away from my PC and am unable to post more code at the moment but if someone could point me in the right direction it would be much appreciated.

Regards.

penpen
Expert
Posts: 1991
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Remove Time Element From File Creation Date

#2 Post by penpen » 22 Jan 2014 04:41

Another for loop, may help you:

Code: Select all

for %%a in (z.txt) do for /F %%A in ("%%~ta") do echo %%A


penpen

Cap'nKirk
Posts: 4
Joined: 22 Jan 2014 03:40

Re: Remove Time Element From File Creation Date

#3 Post by Cap'nKirk » 22 Jan 2014 04:45

Thanks for the reply.

As soon as I am back infront of my PC I'll give it a try

Cap'nKirk
Posts: 4
Joined: 22 Jan 2014 03:40

Re: Remove Time Element From File Creation Date

#4 Post by Cap'nKirk » 24 Jan 2014 07:41

penpen wrote:Another for loop, may help you:

Code: Select all

for %%a in (z.txt) do for /F %%A in ("%%~ta") do echo %%A


penpen


Sorry penpen, I couldn't seem to get that to work.

As I am now infront of my PC, ere the whole code that I have:

Code: Select all

@ECHO OFF &SETLOCAL
(FOR /f "delims=" %%a IN ('dir /b /a-d /s /n "C:\Documents and Settings\All Users\Documents\My Pictures\Pics & Vids"') DO (
    FOR /f "tokens=1-3*" %%x IN ('dir /a-d /tc "%%~a"^|findstr "^[0-9]"') DO (
        ECHO ^<img src="%%a" width="20px" border="2"^>^<a href="%%a"^>%%~nxa^</a^>,%%~ta,%%x ^</br^>
    )
))>DIR.html
TYPE DIR.html


I do not know where to place the snippet that you posted.

Regards..,

Endoro
Posts: 244
Joined: 27 Mar 2013 01:29
Location: Bozen

Re: Remove Time Element From File Creation Date

#5 Post by Endoro » 24 Jan 2014 12:54

Cap'nKirk wrote:I do not know where to place the snippet that you posted.


Always and only on the right place:

Code: Select all

@ECHO OFF &SETLOCAL
(FOR /f "delims=" %%a IN ('dir /b /a-d /s /n "C:\Documents and Settings\All Users\Documents\My Pictures\Pics & Vids"') DO (
    FOR /f "tokens=1-3*" %%x IN ('dir /a-d /tc "%%~a"^|findstr "^[0-9]"') DO (
      for /f %%c in ("%%~ta") do (
         ECHO ^<img src="%%a" width="20px" border="2"^>^<a href="%%a"^>%%~nxa^</a^>,%%~c,%%x ^</br^>
      )
    )
))>DIR.html
TYPE DIR.html

Cap'nKirk
Posts: 4
Joined: 22 Jan 2014 03:40

Re: Remove Time Element From File Creation Date

#6 Post by Cap'nKirk » 25 Jan 2014 09:33

Endoro wrote:
Cap'nKirk wrote:I do not know where to place the snippet that you posted.


Always and only on the right place:

Code: Select all

@ECHO OFF &SETLOCAL
(FOR /f "delims=" %%a IN ('dir /b /a-d /s /n "C:\Documents and Settings\All Users\Documents\My Pictures\Pics & Vids"') DO (
    FOR /f "tokens=1-3*" %%x IN ('dir /a-d /tc "%%~a"^|findstr "^[0-9]"') DO (
      for /f %%c in ("%%~ta") do (
         ECHO ^<img src="%%a" width="20px" border="2"^>^<a href="%%a"^>%%~nxa^</a^>,%%~c,%%x ^</br^>
      )
    )
))>DIR.html
TYPE DIR.html


Perfect, thanks Endoro. :D

Post Reply