Append Date & Time to File name

i have a folder name  LOG .  the  folder contains  a number of files. i want to append  the current date and time to each filename

LOG

PCone.csv

PCTwo.csv

PCThree.csv

i want to add date time to each file in the folder 

output should be 

PCONE 2014-12-16 12:01:44.csv

PCTwo.csv 2014-12-16 12:01:44.csv

PCThree.csv 2014-12-16 12:01:44.csv

December 17th, 2014 5:59am

I know this is probably to late for you but in case others have the same question use the following method:

First example is for Universal Time (London)

Get-Service | Export-Csv c:\temp\Services-$(((get-date).ToUniversalTime()).ToString("yyyyMMddThhmmssZ")).csv

This example is for local time formatted the way I would want it:

"c:\temp\Services-$((get-date).ToString('yyyy-MM-dd hh-mm-ss tt')).csv"

Windows does not allow for a colon ":" to be used in a file name so you will need to choose a different separator. Frankly I'm fine with a hyphen "-" but that might just be me.

The following artical will give you all the formatting options.

https://technet.microsoft.com/en-us/library/ee692801.aspx

Free Windows Admin Tool Kit Click here and download it now
February 14th, 2015 9:31am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics