save files date to compare and delete

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
zaotaobao
Posts: 4
Joined: 05 Jul 2012 03:56

save files date to compare and delete

#1 Post by zaotaobao » 05 Jul 2012 04:08

Hi everybody, i'm trying to save all the dates from temp directory to compare after and if is necessary delete some of them, but i'm not really an expert about batch, and i can't save the file date..what's the problem???

ty for your time,ZTB.






@echo off
setlocal ENABLEEXTENSIONS


PUSHD %jboss_home%\server\default\tmp
echo %CD%


FOR %%x in (*) DO (echo %%~tx
set tomate=%%~tx
echo %tomate%)




the result:

D:\jboss-6.1.0.Final\server\default\tmp
03/07/2012 13:49
%tomate%--->why i can't see the file date?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: save files date to compare and delete

#2 Post by foxidrive » 05 Jul 2012 04:27

You need to process it in the loop or use delayed expansion.

zaotaobao
Posts: 4
Joined: 05 Jul 2012 03:56

Re: save files date to compare and delete

#3 Post by zaotaobao » 05 Jul 2012 04:44

what do you mean?? i'm totally nerd..can you explain with and example?
ty.
ZTB

zaotaobao
Posts: 4
Joined: 05 Jul 2012 03:56

Re: save files date to compare and delete

#4 Post by zaotaobao » 05 Jul 2012 05:05

Well...i have searching....so i decided (by myself :O) to modify script ..but sth is wrong..
anyone have a possible solution..i paid for it with and smile..what is wrong here??
@echo off
setlocal ENABLEDELAYEDEXPANSION
PUSHD %jboss_home%\server\default\tmp
echo %CD%

set COUNT=%DATE% o
FOR %%x in (*) DO (echo %%~tx
echo !COUNT!
set /A COUNT=%%~tx---> :_(
echo !COUNT!
)

ty.

zaotaobao
Posts: 4
Joined: 05 Jul 2012 03:56

Re: save files date to compare and delete

#5 Post by zaotaobao » 05 Jul 2012 05:47

OH yeah!!! if sb needs there is! :)

for %%Q IN (*.*) DO (
set FILETIME=%%~tQ
set PEPE=%%~tQ
echo *************************************************************
echo nombre del fichero:%%Q
echo fecha del fichero:%%~tQ
echo fecha del fichero formatada:%DATE:~6,4%%DATE:~3,2%%DATE:~0,2%
echo fecha del fichero formatada:!PEPE:~6,4!!PEPE:~3,2!!PEPE:~0,2! REM YYYYMMDD!!!!
echo !PEPE!
echo fecha para comparar:%dataComparar2%
echo *************************************************************
)

Post Reply