Page 1 of 1

Remove Time Element From File Creation Date

Posted: 22 Jan 2014 03:49
by Cap'nKirk
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.

Re: Remove Time Element From File Creation Date

Posted: 22 Jan 2014 04:41
by penpen
Another for loop, may help you:

Code: Select all

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


penpen

Re: Remove Time Element From File Creation Date

Posted: 22 Jan 2014 04:45
by Cap'nKirk
Thanks for the reply.

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

Re: Remove Time Element From File Creation Date

Posted: 24 Jan 2014 07:41
by Cap'nKirk
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..,

Re: Remove Time Element From File Creation Date

Posted: 24 Jan 2014 12:54
by Endoro
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

Re: Remove Time Element From File Creation Date

Posted: 25 Jan 2014 09:33
by Cap'nKirk
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