![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | Delete files based on dup names I have a set of xls and csv files, sometimes the names, except the extension, are identicle. How do I delete excel files with duplicate names? Example: I have three files in a folder. File1.xls File1.csv File2.xls I need to delete File1.xls and retain the other two. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Delete files based on dup names You need to be more specific on how we choose which to keep. If there's dup names, do we keep the newest file or if there's dup names, we *always* delete the .xls file and keep the .csv, for example... Marco "newbie2" <newbie2@xxxxxx> wrote in message news:261959AA-F913-4A36-9090-7DB265DE5288@xxxxxx Quote: > I have a set of xls and csv files, sometimes the names, except the > extension, > are identicle. How do I delete excel files with duplicate names? > > Example: I have three files in a folder. > File1.xls > File1.csv > File2.xls > > I need to delete File1.xls and retain the other two. |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Delete files based on dup names Thanks for reply. I should make it more clear. If a dup name is found, I'd always keep csv file, and delete xls file. Timestamp on the file bears no significance. "Marco Shaw [MVP]" wrote: Quote: > You need to be more specific on how we choose which to keep. If there's dup > names, do we keep the newest file or if there's dup names, we *always* > delete the .xls file and keep the .csv, for example... > > Marco > > "newbie2" <newbie2@xxxxxx> wrote in message > news:261959AA-F913-4A36-9090-7DB265DE5288@xxxxxx Quote: > > I have a set of xls and csv files, sometimes the names, except the > > extension, > > are identicle. How do I delete excel files with duplicate names? > > > > Example: I have three files in a folder. > > File1.xls > > File1.csv > > File2.xls > > > > I need to delete File1.xls and retain the other two. > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Delete files based on dup names "newbie2" <newbie2@xxxxxx> wrote in message news:F470CA18-2901-431A-891C-AA11184E5743@xxxxxx Quote: > Thanks for reply. I should make it more clear. > > If a dup name is found, I'd always keep csv file, and delete xls file. > Timestamp on the file bears no significance. Try this: PS>dir|group basename|foreach{if($_.count -gt 1){remove-item ($_.name+".xls") -whatif}} Now, I think the basename property only exists if you're running PowerShell v2... If the above works for you, just remove "-whatif" to actually make it remove the file(s). Marco |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Delete files based on dup names >>> > Now, I think the basename property only exists if you're running Quote: Quote: Quote: >>> > PowerShell v2... Nope, also available in V1.0 ( defined as: [System.IO.Path]::GetFileNameWithoutExtension($this) ) "Marco Shaw [MVP]" <marco.shaw@xxxxxx_SPAMgmail.com> wrote in message news:Oj1VgGoBKHA.3724@xxxxxx Quote: > > > "newbie2" <newbie2@xxxxxx> wrote in message > news:F470CA18-2901-431A-891C-AA11184E5743@xxxxxx Quote: >> Thanks for reply. I should make it more clear. >> >> If a dup name is found, I'd always keep csv file, and delete xls file. >> Timestamp on the file bears no significance. > Does this need to be run recursively? > > Try this: > PS>dir|group basename|foreach{if($_.count -gt 1){remove-item > ($_.name+".xls") -whatif}} > > Now, I think the basename property only exists if you're running > PowerShell v2... > > If the above works for you, just remove "-whatif" to actually make it > remove the file(s). > > Marco |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Can some help? cannot delete files as 'names too long for filesystem' | General Discussion | |||
| Re: CAn some help? cannot delete files as 'names too long for filesystem' | Vista General | |||
| unable to delete Names of files after deleted files. | Vista mail | |||
| Delete files based on last accessed date? | PowerShell | |||
| Delete based on date | PowerShell | |||