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.
Remove Time Element From File Creation Date
Moderator: DosItHelp
Re: Remove Time Element From File Creation Date
Another for loop, may help you:
penpen
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
Thanks for the reply.
As soon as I am back infront of my PC I'll give it a try
As soon as I am back infront of my PC I'll give it a try
Re: Remove Time Element From File Creation Date
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
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
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.