I'm blanking out on this one.
How can I copy files that only have an extension? (Windows 2008R2/Windows7)
Is Powershell my only route? Seems like there should be an easier way to do this.
- Edited by jlcg 14 hours 44 minutes ago
Technology Tips and News
I'm blanking out on this one.
How can I copy files that only have an extension? (Windows 2008R2/Windows7)
Is Powershell my only route? Seems like there should be an easier way to do this.
Reverse method:
PS C:\scripts> 1..12|%{$z=('?'*$_);dir $z}
Directory: C:\scripts
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 11/24/2013 6:20 AM 8 -1
d---- 9/25/2013 12:26 PM wf1
d---- 12/29/2013 9:46 AM wmi
d---- 8/26/2013 3:10 AM test
-a--- 9/9/2013 1:22 PM 0 dhcp
-a--- 9/9/2013 10:32 AM 87 True
-a--- 1/11/2014 4:24 PM 16 xxxx
d---- 12/28/2013 2:24 PM 43024
d---- 6/26/2013 7:22 AM test1
-a--- 12/12/2013 2:28 AM 7 query
d---- 9/2/2013 9:21 AM Rdios
d---- 8/13/2013 12:13 PM tester
d---- 11/28/2013 12:45 PM acltest
d---- 9/5/2013 7:58 AM doctest
d---- 10/4/2013 6:39 AM Outlook
-a--- 9/21/2013 10:24 AM 1713 popcorn
d---- 10/1/2013 12:21 AM Pictures
d---- 9/23/2013 12:41 AM PsTracker
d---- 6/22/2013 9:23 PM iTextSharp
d---- 9/21/2013 1:58 AM test space
-a--- 12/31/2013 9:40 AM 22509 Get-NTPTime
-a--- 9/3/2013 8:58 AM 832 Get-ArpTable
copy .* c:\test
copy .* c:\test
I would write that "How do I copy all files except those that do not have an extension.
The question was asked to exclusively different ways and I posted and answer to both versions as I understood that.
dir *|?{$_.Extension}
copy .* c:\test
Why do you want a list of files but only files that only have extensions? What problem is this solving for you?
Bill
A pattern of *.* should work fine, as far as I know.
Get-ChildItem *.* -File
Edit: The -File switch requires at least PowerShell 3.0. If you're using PowerShell 2.0, you'd need to use the old technique of filtering with Where-Object:
Get-ChildItem *.* | Where-Object { -not $_.PSIsContainer }
Why do you want a list of files but only files that only have extensions? What problem is this solving for you?
Bill
Copying files from a CIFS share on one server to another location for backup purposes.
Basically, the files without a valid extension are massive and don't need to be backed up. Unfortunately, the original location is an appliance and the backup methodology (via NDMP) can't exclude by filenames since it doesn't look at that level, it sees everything as a Filesystem.
If I copy the files that do need to be backed up (anything with an extension) to a Windows Server then I can back up that location.
See David Wyatt's last answer - *.* -file on PowerShell 3.0 or *.* | where-object { -not $_.PSIsContainer } for earlier versions.
Bill