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 :)
rename-item c:\folder\dailybackup.bak -newname ($datetime + ".bak")
--
WBR, Vadims Podans
MVP: PowerShell
PowerShell blog - www.sysadmins.lv
"Emo" <ericn...@gmail.com> rakstija zinojuma
"news:ba9d2a06-5621-4a0c...@q7g2000yqi.googlegroups.com"...
Thanks again
On Sep 10, 10:28 am, "Vadims Podans [MVP]" <vpodans> wrote:
> IIUC, you need this:
>
> rename-item c:\folder\dailybackup.bak -newname ($datetime + ".bak")
> --
> WBR, Vadims Podans
> MVP: PowerShell
> PowerShell blog -www.sysadmins.lv
>
> "Emo" <ericnmo...@gmail.com> rakstija zinojuma
> "news:ba9d2a06-5621-4a0c...@q7g2000yqi.googlegroups.com"...
>
>
>
> > 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 :)- Hide quoted text -
>
> - Show quoted text -