![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | removing selected file that contain special characters I had posted this on the windows.server.scripting newsgroup before realising that there was a powershell newsgroup. Can anyone help? How can I remove selected files that have special characters in it's name? I'm trying to remove old cookies. I can list them using gci | where {$_.lastwritetime -le [datetime]::now.adddays(-60)} but if I then try to delete them gci | where {$_.lastwritetime -le [datetime]::now.adddays(-60)} | rm it fails to remove any files. The files are cookies and have file names like user@a.site.com[2].txt If i run the command "gci | rm" from a folder that contains some cookie files and other files, only the files without special characters gets deleted. Any help appreciated. |
| | #2 (permalink) |
| Guest | RE: removing selected file that contain special characters Square brackets are used as wildcard characters similar to "*" and "?". Thus, you sometimes need to use the -LiteralPath parameter for certain cmdlets when dealing with such path names. However, I thought that the literal interpretation is default when a path is piped into the cmdlet. Maybe this is a bug (there are some more problems like this in version 1). Does the following workaround delete those files? gci | where {$_.lastwritetime -le [datetime]::now.adddays(-60)} | foreach-object { rm -literalpath $_ } -- greetings dreeschkind "Paul" wrote: > I had posted this on the windows.server.scripting newsgroup before realising > that there was a powershell newsgroup. Can anyone help? > > How can I remove selected files that have special characters in it's name? > I'm trying to remove old cookies. I can list them using > > gci | where {$_.lastwritetime -le [datetime]::now.adddays(-60)} > > but if I then try to delete them > > gci | where {$_.lastwritetime -le [datetime]::now.adddays(-60)} | rm > > it fails to remove any files. The files are cookies and have file names like > user@a.site.com[2].txt > > If i run the command "gci | rm" from a folder that contains some cookie > files and other files, only the files without special characters gets deleted. > > Any help appreciated. > |
| | #3 (permalink) |
| Guest | RE: removing selected file that contain special characters When I try to run the code below I get the error: Remove-Item : A parameter cannot be found that matches parameter name 'Literalpath'. I am running powershell version 1.0.9567.1 . Has the Literalpath been introduced in a newer version? Thanks for your quick response dreeschkind Paul. "dreeschkind" wrote: > Square brackets are used as wildcard characters similar to "*" and "?". > Thus, you sometimes need to use the -LiteralPath parameter for certain > cmdlets when dealing with such path names. However, I thought that the > literal interpretation is default when a path is piped into the cmdlet. Maybe > this is a bug (there are some more problems like this in version 1). > Does the following workaround delete those files? > > gci | where {$_.lastwritetime -le [datetime]::now.adddays(-60)} > | foreach-object { rm -literalpath $_ } > > -- > greetings > dreeschkind > > "Paul" wrote: > > > I had posted this on the windows.server.scripting newsgroup before realising > > that there was a powershell newsgroup. Can anyone help? > > > > How can I remove selected files that have special characters in it's name? > > I'm trying to remove old cookies. I can list them using > > > > gci | where {$_.lastwritetime -le [datetime]::now.adddays(-60)} > > > > but if I then try to delete them > > > > gci | where {$_.lastwritetime -le [datetime]::now.adddays(-60)} | rm > > > > it fails to remove any files. The files are cookies and have file names like > > user@a.site.com[2].txt > > > > If i run the command "gci | rm" from a folder that contains some cookie > > files and other files, only the files without special characters gets deleted. > > > > Any help appreciated. > > |
| | #4 (permalink) |
| Guest | RE: removing selected file that contain special characters The RTM version shows version 1.0.0.0 Did you update to the RTM version? Can download from here http://www.microsoft.com/windowsserv.../download.mspx -- Richard Siddaway Please note that all scripts are supplied "as is" and with no warranty "Paul" wrote: > When I try to run the code below I get the error: > > Remove-Item : A parameter cannot be found that matches parameter name > 'Literalpath'. > > I am running powershell version 1.0.9567.1 . Has the Literalpath been > introduced in a newer version? > > Thanks for your quick response dreeschkind > Paul. > > > > "dreeschkind" wrote: > > > Square brackets are used as wildcard characters similar to "*" and "?". > > Thus, you sometimes need to use the -LiteralPath parameter for certain > > cmdlets when dealing with such path names. However, I thought that the > > literal interpretation is default when a path is piped into the cmdlet. Maybe > > this is a bug (there are some more problems like this in version 1). > > Does the following workaround delete those files? > > > > gci | where {$_.lastwritetime -le [datetime]::now.adddays(-60)} > > | foreach-object { rm -literalpath $_ } > > > > -- > > greetings > > dreeschkind > > > > "Paul" wrote: > > > > > I had posted this on the windows.server.scripting newsgroup before realising > > > that there was a powershell newsgroup. Can anyone help? > > > > > > How can I remove selected files that have special characters in it's name? > > > I'm trying to remove old cookies. I can list them using > > > > > > gci | where {$_.lastwritetime -le [datetime]::now.adddays(-60)} > > > > > > but if I then try to delete them > > > > > > gci | where {$_.lastwritetime -le [datetime]::now.adddays(-60)} | rm > > > > > > it fails to remove any files. The files are cookies and have file names like > > > user@a.site.com[2].txt > > > > > > If i run the command "gci | rm" from a folder that contains some cookie > > > files and other files, only the files without special characters gets deleted. > > > > > > Any help appreciated. > > > |
| | #5 (permalink) |
| Guest | RE: removing selected file that contain special characters Richard is correct, your version looks like PowerShell RC1. The LiteralPath workaround has been introduced with RC2. See the following section on the PowerShell blog: "Access files and directories with special character names" http://blogs.msdn.com/powershell/arc...se-Notes-.aspx -- greetings dreeschkind "Paul" wrote: > When I try to run the code below I get the error: > > Remove-Item : A parameter cannot be found that matches parameter name > 'Literalpath'. > > I am running powershell version 1.0.9567.1 . Has the Literalpath been > introduced in a newer version? > > Thanks for your quick response dreeschkind > Paul. > > > > "dreeschkind" wrote: > > > Square brackets are used as wildcard characters similar to "*" and "?". > > Thus, you sometimes need to use the -LiteralPath parameter for certain > > cmdlets when dealing with such path names. However, I thought that the > > literal interpretation is default when a path is piped into the cmdlet. Maybe > > this is a bug (there are some more problems like this in version 1). > > Does the following workaround delete those files? > > > > gci | where {$_.lastwritetime -le [datetime]::now.adddays(-60)} > > | foreach-object { rm -literalpath $_ } > > > > -- > > greetings > > dreeschkind > > > > "Paul" wrote: > > > > > I had posted this on the windows.server.scripting newsgroup before realising > > > that there was a powershell newsgroup. Can anyone help? > > > > > > How can I remove selected files that have special characters in it's name? > > > I'm trying to remove old cookies. I can list them using > > > > > > gci | where {$_.lastwritetime -le [datetime]::now.adddays(-60)} > > > > > > but if I then try to delete them > > > > > > gci | where {$_.lastwritetime -le [datetime]::now.adddays(-60)} | rm > > > > > > it fails to remove any files. The files are cookies and have file names like > > > user@a.site.com[2].txt > > > > > > If i run the command "gci | rm" from a folder that contains some cookie > > > files and other files, only the files without special characters gets deleted. > > > > > > Any help appreciated. > > > |
| | #6 (permalink) |
| Guest | RE: removing selected file that contain special characters Thank you both for your replies. I didn't realised that the old version was installed. I have tested this using version 1 and it works fine. I assumed the host version greater than 1.0 ment I had the new version :-( Paul. "dreeschkind" wrote: > Richard is correct, your version looks like PowerShell RC1. > The LiteralPath workaround has been introduced with RC2. > > See the following section on the PowerShell blog: > "Access files and directories with special character names" > http://blogs.msdn.com/powershell/arc...se-Notes-.aspx > > -- > greetings > dreeschkind > > "Paul" wrote: > > > When I try to run the code below I get the error: > > > > Remove-Item : A parameter cannot be found that matches parameter name > > 'Literalpath'. > > > > I am running powershell version 1.0.9567.1 . Has the Literalpath been > > introduced in a newer version? > > > > Thanks for your quick response dreeschkind > > Paul. > > > > > > > > "dreeschkind" wrote: > > > > > Square brackets are used as wildcard characters similar to "*" and "?". > > > Thus, you sometimes need to use the -LiteralPath parameter for certain > > > cmdlets when dealing with such path names. However, I thought that the > > > literal interpretation is default when a path is piped into the cmdlet. Maybe > > > this is a bug (there are some more problems like this in version 1). > > > Does the following workaround delete those files? > > > > > > gci | where {$_.lastwritetime -le [datetime]::now.adddays(-60)} > > > | foreach-object { rm -literalpath $_ } > > > > > > -- > > > greetings > > > dreeschkind > > > > > > "Paul" wrote: > > > > > > > I had posted this on the windows.server.scripting newsgroup before realising > > > > that there was a powershell newsgroup. Can anyone help? > > > > > > > > How can I remove selected files that have special characters in it's name? > > > > I'm trying to remove old cookies. I can list them using > > > > > > > > gci | where {$_.lastwritetime -le [datetime]::now.adddays(-60)} > > > > > > > > but if I then try to delete them > > > > > > > > gci | where {$_.lastwritetime -le [datetime]::now.adddays(-60)} | rm > > > > > > > > it fails to remove any files. The files are cookies and have file names like > > > > user@a.site.com[2].txt > > > > > > > > If i run the command "gci | rm" from a folder that contains some cookie > > > > files and other files, only the files without special characters gets deleted. > > > > > > > > Any help appreciated. > > > > |
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Desktop Search and special characters | doraz | Vista file management | 0 | 08-01-2008 04:22 PM |
| Typing in special characters bug | Spart | Vista General | 1 | 02-15-2008 01:21 PM |
| Special Characters - how? | euroeddie | Vista General | 6 | 04-24-2007 08:38 PM |
| How to run program with special characters | marc | PowerShell | 4 | 03-05-2007 03:22 PM |
| Using Paths with Special Characters and/or Spaces | public.microsoft.com | PowerShell | 5 | 08-06-2006 12:22 PM |