Tools@BasicAware

RENToday

Purpose

Changes the name of one or more files to today's date/time. The number of renamed files is returned via the ERRORLEVEL environment variable.

The (new) file name is created in the format YearMonthDay_HourMinuteSecond_Millisecond, e.g. 20161109_120136_244.log. The millisecond part ensures unique file names, when used to rename files in a directory. To further prevent equal name collissions, a forced three millisecond delay has been implemented.

Example in a batch file, assuming three *.log files in the target folder:

RENToday /d=.\data\logs\*.log
ECHO From batch: %ERRORLEVEL% file(s) renamed.

... results in ...

• RENToday v1.6.0 •
Copyright © 2002-2018 by BasicAware. All rights reserved.
Written by Knuth Konrad

Source directory: .\data\logs\*.log
Overwrite       : False
Prefix          :

-- Scanning folder .\data\logs
 Renaming .\data\logs\sa3423.log
  -> .\data\logs\20161109_115656_529.log
 Renaming .\data\logs\sa3424.log
  -> .\data\logs\20161109_115656_544.log
 Renaming .\data\logs\sa3444.log
  -> .\data\logs\20161109_115656_560.log

File(s) renamed: 3

From batch: 3 file(s) renamed.


Download

Command line application RENToday


Installation

None. Download the ZIP file, extract the included executable and run it.

Please note: this is a console application. You should run it from a command prompt.


Use case(s)


Syntax

RENToday /f=<Filename>|/d=<Directory with file spec> [/p=<Prefix>] [/o]

Examples

RENToday /f=C:\MyApplication\Application.log /o

Assuming the current date and time (at this server), Application.log will be renamed to 20240516_165417_841.log.

RENToday /f=C:\MyApplication\Application.log /p=LOG_ /o

Assuming the current date and time (at this server), Application.log will be renamed to LOG_20240516_165417_841.log.

RENToday /f=C:\MyApplication\Application.log /p=LOG_*_ /o

Assuming the current date and time (at this server), Application.log will be renamed to LOG_Application_20240516_165417_841.log.


Source code

The PowerBASIC source code is available at Github


Known issues / limitations


Version

16.05.2024

Navigation

Tools

Info

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Germany License .
All contents copyright © 2012-2024 by BasicAware, Knuth Konrad