![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | ren filename with time help Hi Gang, I'm driving myself crazy with this problem! Goal, write a logfile with current time as the filename... examples being: $time1=get-date -UFormat "%H%M-%d%m%y" get-ExecutionPolicy >> $time1.log ///completes but no file is created/// PS C:\temp> $time1 1936-051108 ///ok let's try it like this/// PS C:\temp> ren c:\temp\test.log -newname $time1 ///this works but no file extension???/// PS C:\temp> ren c:\temp\test.log -newname $time1.log Rename-Item : Cannot bind argument to parameter 'NewName' because it is null. At line:1 char:30 + ren c:\temp\test.log -newname <<<< $time1.log thanks in advance! |
My System Specs![]() |
| | #2 (permalink) |
| | Re: ren filename with time help On Nov 6, 11:20*am, Joe <joedon...@xxxxxx> wrote: Quote: > Hi Gang, > > I'm driving myself crazy with this problem! *Goal, write a logfile > with current time as the filename... > > examples being: > > $time1=get-date -UFormat "%H%M-%d%m%y" > get-ExecutionPolicy >> $time1.log > ///completes but no file is created/// > > PS C:\temp> $time1 > 1936-051108 > > ///ok let's try it like this/// > PS C:\temp> ren c:\temp\test.log -newname $time1 > ///this works but no file extension???/// > > PS C:\temp> ren c:\temp\test.log -newname $time1.log > Rename-Item : Cannot bind argument to parameter 'NewName' because it > is null. > At line:1 char:30 > + ren c:\temp\test.log -newname <<<< *$time1.log > > thanks in advance! Get-ExecutionPolicy > "$( Get-Date -UFormat '%H%M-%d%m%y' ).log" When you put .log on the end of a variable name, PowerShell thinks it is a property named "log", and will try to evaluate it. Because it evaluates to null, no file is created. Jeff |
My System Specs![]() |
| | #3 (permalink) |
| | Re: ren filename with time help On Nov 6, 12:37*pm, Jeff <jeff.hill...@xxxxxx> wrote: Quote: > On Nov 6, 11:20*am, Joe <joedon...@xxxxxx> wrote: > > > Quote: > > Hi Gang, Quote: > > I'm driving myself crazy with this problem! *Goal, write a logfile > > with current time as the filename... Quote: > > examples being: Quote: > > $time1=get-date -UFormat "%H%M-%d%m%y" > > get-ExecutionPolicy >> $time1.log > > ///completes but no file is created/// Quote: > > PS C:\temp> $time1 > > 1936-051108 Quote: > > ///ok let's try it like this/// > > PS C:\temp> ren c:\temp\test.log -newname $time1 > > ///this works but no file extension???/// Quote: > > PS C:\temp> ren c:\temp\test.log -newname $time1.log > > Rename-Item : Cannot bind argument to parameter 'NewName' because it > > is null. > > At line:1 char:30 > > + ren c:\temp\test.log -newname <<<< *$time1.log Quote: > > thanks in advance! > Try this: > > Get-ExecutionPolicy > "$( Get-Date -UFormat '%H%M-%d%m%y' ).log" > > When you put .log on the end of a variable name, PowerShell thinks it > is a property named "log", and will try to evaluate it. *Because it > evaluates to null, no file is created. > > Jeff ![]() |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Re: How can I search for a ( in the filename only? | Vista General | |||
| about 8.3 filename | Vista General | |||
| Add Date and time to filename | PowerShell | |||
| Get-Acl for filename containing [ and ] | PowerShell | |||
| What is the RC2 filename please? | Vista General | |||