Tags

Howto (51) Free Software (35) Powershell (33) Windows Server (23) AD (16) Hyper-V (16) Exchange (13) Office (13) Group Policy (10) Windows Server 2012 (9) Scripts (7) Symantec BE (5) Windows 8 (5) Cisco (4) TMG (4) Terminal Server (4) Cluster (3) HP (3) RDS (3) UAG (3) Citrix (2) DC (2) DNS (2) IE10 (2) OpenID (2) PKI (2) SCVMM (2) Windows Live (2) iLO (2) Backup (1) DPM (1) Fileserver (1) IE (1) SQL; DPM (1) Security (1) Sharepoint (1) Switch (1) VMWare (1) Veeam (1)

dinsdag 6 maart 2012

Datum en Tijd in batchbestand gebruiken

Onderstaande batch file zorgt ervoor dat een te importeren bestand wordt zodanig hernoemd dat de datum en tijd ervoor komt te staan. Wat handig is voor de chronologische volgorde.


@Echo Off
@For /F "tokens=2,3,4 delims=- " %%A in ('echo %date%') do @(
Set Day=%%A
Set Month=%%B
Set Year=%%C
Set YMD=%%C%%B%%A
)

 @For /F "tokens=1,2,3 delims=:, " %%A in ('echo %time%') do @(
Set Hour=%%A
Set Min=%%B
Set Sec=%%C
Set UMS=%%A%%B%%C
)

ren "C:\TEMP\Test\bestand.csv" "%YMD%-%UMS%-bestand.csv"

(when language settings of the logged on user are set to English, the delims of date and time change from resp "-" to "/" and from ":," to ":.")

Geen opmerkingen:

Een reactie posten