PowerShell Code snippet to copy files with a particular extension.
$extension = ('.pdf', '.docx', '.txt')
Gci d:\WorkFolder $_ | Where-Object {
$extension -contains $_.Extension
} | % {Copy-Item $_.FullName d:\mix_backup}
To read files with specified filename extension.
$extension = ('.pdf', '.docx', '.txt')
Dir d:\WorkFolder $_ | Where-Object {
$extension -contains $_.Extension
}
or
$extension = ('.pdf', '.docx', '.txt')
Gci d:\WorkFolder $_ | Where-Object {
$extension -contains $_.Extension
} | % {write-host $_.FullName }
Copying files with the long path will result to an error.
Robocopy a command line tool is able to copy files exceeding 256 characters.
Below is the modified code that uses robocopy to copy files with long paths.
Do not interchange source and destination when using robocopy, the files will be overwritten.
$extension = ('.pdf', '.jpg', '.txt')
gci d:\WorkFolder $_ | Where-Object {
$extension -contains $_.Extension
} | % { robocopy /s d:\WorkFolder d:\xtra_copy $_.Name }
Source: D:\WorkFolder
Destination: D:\xtra_copy
Change the source and destination to your own path. Please make sure that paths are not reversed or interchanged.
If paths are swap there is a high risk of data corruption or loss of data.
Robocopy a command line tool is able to copy files exceeding 256 characters.
Below is the modified code that uses robocopy to copy files with long paths.
Do not interchange source and destination when using robocopy, the files will be overwritten.
$extension = ('.pdf', '.jpg', '.txt')
gci d:\WorkFolder $_ | Where-Object {
$extension -contains $_.Extension
} | % { robocopy /s d:\WorkFolder d:\xtra_copy $_.Name }
Source: D:\WorkFolder
Destination: D:\xtra_copy
Change the source and destination to your own path. Please make sure that paths are not reversed or interchanged.
If paths are swap there is a high risk of data corruption or loss of data.
===================================
Free Android Apps:
Click on links below to find out more:
Excel Keyboard shortcuts guide
https://play.google.com/store/apps/details?id=chrisjoms.myexcelapplicationguide
Linux Android App cheat sheet:
https://play.google.com/store/apps/details?id=com.LinuxMobileKit
https://play.google.com/store/apps/details?id=soulrefresh.beautiful.prayer
Catholic Rosary Guide for Android:
https://play.google.com/store/apps/details?id=com.myrosaryapp
http://quickbytesstuff.blogspot.sg/2014/09/how-to-recite-rosary.html
Divine Mercy Chaplet Guide (A Powerful prayer):
https://play.google.com/store/apps/details?id=com.dmercyapp
Free Android Apps:
Click on links below to find out more:
Excel Keyboard shortcuts guide
https://play.google.com/store/apps/details?id=chrisjoms.myexcelapplicationguide
Linux Android App cheat sheet:
https://play.google.com/store/apps/details?id=com.LinuxMobileKit
https://play.google.com/store/apps/details?id=soulrefresh.beautiful.prayer
Catholic Rosary Guide for Android:
https://play.google.com/store/apps/details?id=com.myrosaryapp
http://quickbytesstuff.blogspot.sg/2014/09/how-to-recite-rosary.html
Divine Mercy Chaplet Guide (A Powerful prayer):
https://play.google.com/store/apps/details?id=com.dmercyapp
Comments
Post a Comment