<> wrote in message
Emo於 2009年9月10日星期四UTC+8下午11時20分21秒寫道:
I hope this is simple :)
I'm looking to rename a file in C:\folder\dailybackup.bak to C:\folder \MMddyy-hhmm.bak
I just need to do it for one file. The original filename with always
be "dailybackup.bak"
I understand how to use get-date and how to format it as in:
$datetime = get-date -f MMddyy-hhmmtt (using tt for am or pm)
And I understand how to do a simple file rename using ren. In rename,
it asks for the path and then NewName...but I can't figure out how to
get the info from $datetime into the filename.
so...how can I rename the file using the info from $datetime?
I'm pretty new to powershell so any help is greatly appreciated :)
try this
Rename-Item C:\foldername "$((get-date).toString('foldername_dd-MM-yyyy'))"
On Fri, 7 Aug 2015 11:45:21 -0700 (PDT), navan...@gmail.com wrote in microsoft.public.windows.powershell:
On Thursday, September 10, 2009 at 10:20:21 AM UTC-5, Emo wrote:Oh, it took you only 6 years to check the command?
$datetime = get-date -f MMddyy-hhmmtt (using tt for am or pm)
the above command is not working"is not working" is a very useless problem description.
This command is working perfectly fine with me.
It assigns the current date/time to $datetime.
What did you expect it to do?
And what did you observe it doing instead?
Just saying "is not working" without providing those 2 critical details
is pointless.
jue
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 72:34:13 |
Calls: | 6,657 |
Calls today: | 3 |
Files: | 12,203 |
Messages: | 5,332,304 |
Posted today: | 1 |