Ms-Dos - Convertir fecha a Juliana para comparar fechas

 
Vista:

Convertir fecha a Juliana para comparar fechas

Publicado por amparitohijo (94 intervenciones) el 22/10/2009 12:53:27
Buenas.

He estado dándole vueltas un tiempo, y he creado un script que traduce las fechas de archivos a fechas Julianas, pudiendo de esta forma operar con ellas.
Por ejemplo, borrar archivos con más de "n" días de antigüedad...

La base la he sacado de aquí:
http://wapedia.mobi/es/Conversi%C3%B3n_de_coordenadas_ecuatoriales_a_coordenadas_horarias

Si alguien cree que es útil, que me lo diga y lo publico.

Salu2
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Convertir fecha a Juliana para comparar fechas

Publicado por Sebastian (1 intervención) el 21/01/2010 14:40:21
Me seria de mucha utilidad si lo publicas. Desde ya muchas gracias!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Convertir fecha a Juliana para comparar fechas

Publicado por amparito (94 intervenciones) el 03/02/2010 10:36:21
Buenas.

He encontrado una herramienta de Windows que permite filtrar por fecha para poder realizar acciones con los archivos que sigan ciertos criterios. Es bastante más eficiente (que no eficaz) que mi código, y mucho más sencillo de entender y de utilizar.

Nombre: FORFILES.EXE
Ubicación: C:\WINDOWS\SYSTEM32\

Funcionamiento (forfiles /? para mostrar esta ayuda):

C:\WINDOWS\system32>forfiles.exe /?

FORFILES [/P pathname] [/M searchmask] [/S]
[/C command] [/D [+ | -] {dd/MM/yyyy | dd}]

Description:
Selects a file (or set of files) and executes a
command on that file. This is helpful for batch jobs.

Parameter List:
/P pathname Indicates the path to start searching.
The default folder is the current working
directory (.).

/M searchmask Searches files according to a searchmask.
The default searchmask is '*' .

/S Instructs forfiles to recurse into
subdirectories. Like "DIR /S".

/C command Indicates the command to execute for each file.
Command strings should be wrapped in double
quotes.

The default command is "cmd /c echo @file".

The following variables can be used in the
command string:
@file - returns the name of the file.
@fname - returns the file name without
extension.
@ext - returns only the extension of the
file.
@path - returns the full path of the file.
@relpath - returns the relative path of the
file.
@isdir - returns "TRUE" if a file type is
a directory, and "FALSE" for files.
@fsize - returns the size of the file in
bytes.
@fdate - returns the last modified date of the
file.
@ftime - returns the last modified time of the
file.

To include special characters in the command
line, use the hexadecimal code for the character
in 0xHH format (ex. 0x09 for tab). Internal
CMD.exe commands should be preceded with
"cmd /c".

/D date Selects files with a last modified date greater
than or equal to (+), or less than or equal to
(-), the specified date using the
"dd/MM/yyyy" format; or selects files with a
last modified date greater than or equal to (+)
the current date plus "dd" days, or less than or
equal to (-) the current date minus "dd" days. A
valid "dd" number of days can be any number in
the range of 0 - 32768.
"+" is taken as default sign if not specified.

/? Displays this help message.

Examples:
FORFILES /?
FORFILES
FORFILES /P C:\WINDOWS /S /M DNS*.*
FORFILES /S /M *.txt /C "cmd /c type @file | more"
FORFILES /P C:\ /S /M *.bat
FORFILES /D -30 /M *.exe
/C "cmd /c echo @path 0x09 was changed 30 days ago"
FORFILES /D 01/01/2001
/C "cmd /c echo @fname is new since Jan 1st 2001"
FORFILES /D +3/2/2010 /C "cmd /c echo @fname is new today"
FORFILES /M *.exe /D +1
FORFILES /S /M *.doc /C "cmd /c echo @fsize"
FORFILES /M *.txt /C "cmd /c if @isdir==FALSE notepad.exe @file"

C:\WINDOWS\system32>

Espero que os sea de utilidad.
No obstante, si alguien siente la necesidad de ver el código, que me lo diga y se lo mando por email.

Salu2
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Convertir fecha a Juliana para comparar fechas

Publicado por amparito (94 intervenciones) el 03/02/2010 10:54:34
Hola otra vez.

Se me olvidó comentar que este comando (FORFILES.EXE) sólo está disponible en las versiones Server de Windows 2000 y 2003. No obstante, si copias el ".exe" a un XP o a un Vista (a la carpeta C:\\windows\system32 para poder ejecutarlo desde cualquier ubicación), funciona a la perfección.

Salu2
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Convertir fecha a Juliana para comparar fechas

Publicado por Jose (1 intervención) el 11/01/2013 14:26:24
Hola,
me interesaría saber como pasar de gregoriana a juliana, para restar 30 días y volver a pasar a gregoriana.

Gracias.
Jose.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar