![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | get-date - make it a filename $WshShell = New-Object -ComObject WScript.Shell $wshshell.run("winzip32 -m 'c:\$(Get-Date -format 'yyyy MMM d').zip' $dir_source") I would like my zip file to be "2008 nov 5.zip" ..however powershell zip the file to "2008.zip" How can i make the date as part of the file ? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: get-date - make it a filename Hello IT, Try this way: $fileName = "C:\{0:yyyy MMM d}.zip" -f (get-date) & winzip32 -m "$fileName" "$dir_source" --- Shay Levy Windows PowerShell MVP http://blogs.microsoft.co.il/blogs/ScriptFanatic PowerShell Toolbar: http://tinyurl.com/PSToolbar IS> $WshShell = New-Object -ComObject WScript.Shell IS> $wshshell.run("winzip32 -m 'c:\$(Get-Date -format 'yyyy MMM d').zip' IS> $dir_source") IS> IS> I would like my zip file to be "2008 nov 5.zip" ..however powershell IS> zip the file to "2008.zip" IS> IS> How can i make the date as part of the file ? IS> |
My System Specs![]() |
| | #3 (permalink) |
| | Re: get-date - make it a filename although $filename looks ok as a string, however $wshshell.run("winzip32 -m $filename $dir_source") ==> still not able to recognise full string of $filename. How can i enscapulate $filename into the Run method ? "Shay Levy [MVP]" <no@xxxxxx> wrote in message news:89228ed2505868cb0d49a05a3a6a@xxxxxx Quote: > Hello IT, > > > Try this way: > > > $fileName = "C:\{0:yyyy MMM d}.zip" -f (get-date) > & winzip32 -m "$fileName" "$dir_source" > > > > > --- > Shay Levy > Windows PowerShell MVP > http://blogs.microsoft.co.il/blogs/ScriptFanatic > PowerShell Toolbar: http://tinyurl.com/PSToolbar > > > IS> $WshShell = New-Object -ComObject WScript.Shell > IS> $wshshell.run("winzip32 -m 'c:\$(Get-Date -format 'yyyy MMM d').zip' > IS> $dir_source") > IS> IS> I would like my zip file to be "2008 nov 5.zip" ..however > powershell > IS> zip the file to "2008.zip" > IS> IS> How can i make the date as part of the file ? > IS> > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: get-date - make it a filename I think the embedded spaces in the filename are messing with the parsing. Try quoting the $filename, and escaping the quotes with backticks: $wshshell.run("winzip32 -m `"$filename`" $dir_source") I try to avoid using filenames with embedded spaces because it tends to confuse the parser. "IT Staff" wrote: Quote: > although $filename looks ok as a string, however > > $wshshell.run("winzip32 -m $filename $dir_source") ==> still not able to > recognise full string of $filename. > > How can i enscapulate $filename into the Run method ? > > > > > "Shay Levy [MVP]" <no@xxxxxx> wrote in message > news:89228ed2505868cb0d49a05a3a6a@xxxxxx Quote: > > Hello IT, > > > > > > Try this way: > > > > > > $fileName = "C:\{0:yyyy MMM d}.zip" -f (get-date) > > & winzip32 -m "$fileName" "$dir_source" > > > > > > > > > > --- > > Shay Levy > > Windows PowerShell MVP > > http://blogs.microsoft.co.il/blogs/ScriptFanatic > > PowerShell Toolbar: http://tinyurl.com/PSToolbar > > > > > > IS> $WshShell = New-Object -ComObject WScript.Shell > > IS> $wshshell.run("winzip32 -m 'c:\$(Get-Date -format 'yyyy MMM d').zip' > > IS> $dir_source") > > IS> IS> I would like my zip file to be "2008 nov 5.zip" ..however > > powershell > > IS> zip the file to "2008.zip" > > IS> IS> How can i make the date as part of the file ? > > IS> > > > > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: get-date - make it a filename yes that is the backtick i m looking for ..thanks "Rob Campbell" <RobCampbell@xxxxxx> wrote in message news:C2469850-6802-4E6A-B27B-233081F7AAA3@xxxxxx Quote: >I think the embedded spaces in the filename are messing with the parsing. > > Try quoting the $filename, and escaping the quotes with backticks: > > $wshshell.run("winzip32 -m `"$filename`" $dir_source") > > I try to avoid using filenames with embedded spaces because it tends to > confuse the parser. > > "IT Staff" wrote: > Quote: >> although $filename looks ok as a string, however >> >> $wshshell.run("winzip32 -m $filename $dir_source") ==> still not able to >> recognise full string of $filename. >> >> How can i enscapulate $filename into the Run method ? >> >> >> >> >> "Shay Levy [MVP]" <no@xxxxxx> wrote in message >> news:89228ed2505868cb0d49a05a3a6a@xxxxxx Quote: >> > Hello IT, >> > >> > >> > Try this way: >> > >> > >> > $fileName = "C:\{0:yyyy MMM d}.zip" -f (get-date) >> > & winzip32 -m "$fileName" "$dir_source" >> > >> > >> > >> > >> > --- >> > Shay Levy >> > Windows PowerShell MVP >> > http://blogs.microsoft.co.il/blogs/ScriptFanatic >> > PowerShell Toolbar: http://tinyurl.com/PSToolbar >> > >> > >> > IS> $WshShell = New-Object -ComObject WScript.Shell >> > IS> $wshshell.run("winzip32 -m 'c:\$(Get-Date -format 'yyyy MMM >> > d').zip' >> > IS> $dir_source") >> > IS> IS> I would like my zip file to be "2008 nov 5.zip" ..however >> > powershell >> > IS> zip the file to "2008.zip" >> > IS> IS> How can i make the date as part of the file ? >> > IS> >> > >> >> |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Modified Date used as Date Taken in Photo Gallery and Digital Imag | Vista music pictures video | |||
| Photo date taken vs. file date | Vista music pictures video | |||
| How do I make an end date for a recurring appointment in Calendar? | Vista General | |||
| Add Date and time to filename | PowerShell | |||