How to copy all files by specified extension to another location recursively

Carmageddon

I was trying the accepted solution here: https://serverfault.com/questions/194827/writing-a-powershell-script-to-copy-files-with-certain-extension-from-one-folder/223014#223014 But it doesnt work, and my comment on the accepted solution is not getting a response.

I am trying to copy all pictures I have in my Pictures drive (only PNG, JPG, without the video files) to a different drive, but having no luck.

Ideally I want to copy recursively, but to a flat destination (not mirroring the source sub-directories)

I tried this command: Copy-Item -path "C:\Users\genadi\Pictures\" -include "*.JPG", "*.PNG" -Destination "D:\" with and without -recurse but nothing happens.

Ideally, I want a script that will 1) reduce original size of all JPG and PNG pictures (including all sub-folders) and 2) copy the reduced size to specified destination.

Currently my originals are about 20GB, I need to fit them on a flash drive for display/printing purposes etc. and easily repeat this when needed (hence why script would be nice).

spacenomyous

That's because the object name returned by the cmdlet doesn't include the extension, you need to append \*. I'm not sure if Copy-Item allows you to "collapse" the destination directory, so I would use Get-ChildItem with -Recurse and pipe it to Copy-Item

Get-ChildItem -Path "C:\Users\genadi\Pictures\*" -Include *.jpg,*.png -Recurse | Copy-Item -Destination D:\

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Search a directory recursively for files listed in a csv, and copy them to another location

From Dev

recursively copy all files from one directory to another with exceptions

From Dev

Copy all files with certain extension to another directory, while changing the extension

From Dev

How can I recursively copy files by file extension?

From Dev

How to copy all files in directory recursively and unzip compressed files on fly

From Dev

How to recursively list all files of desired file type in a specified directory?

From Dev

Copy all excel files from one location to another

From Dev

How do I copy all files recursively to a flat directory in Ruby?

From Dev

How to copy recursively all files not older than 1 day?

From Dev

How to copy "just files" recursively

From Dev

How to copy only files in a specified directory to another folder

From Dev

Recursively delete all files with a given extension

From Dev

recursively display all files with certain extension

From Dev

Recursively copy files from one directory to another

From Dev

Recursively copy files from one directory to another

From Dev

Copy all files recursively without replacing

From Dev

How to copy files with a particular extension from one directory to another in linux

From Dev

How can I recursively copy files by file extension, preserving directory structure?

From Dev

list all the files with the same extension as specified by the user

From Dev

How can I recursively delete all files of a specific extension in the current directory?

From Dev

How can I recursively delete all files of a specific extension in the current directory?

From Dev

AzCopy - how to copy ALL blobs from one storage account to another recursively starting from root$

From Dev

How can I recursively copy all pdf files in a directory (and it's subdirectories) into a single output directory?

From Dev

How to copy all of the files from one directory to another in a bash script

From Dev

How to move all files in dir to another, but copy latest?

From Dev

Copy files that partially matches another files in another location

From Dev

Linux: Copy all files by extension to single dirrectory

From Dev

Recursively execute all files with a specific extension via command line

From Dev

Recursively add suffix after extension to all files in a directory

Related Related

  1. 1

    Search a directory recursively for files listed in a csv, and copy them to another location

  2. 2

    recursively copy all files from one directory to another with exceptions

  3. 3

    Copy all files with certain extension to another directory, while changing the extension

  4. 4

    How can I recursively copy files by file extension?

  5. 5

    How to copy all files in directory recursively and unzip compressed files on fly

  6. 6

    How to recursively list all files of desired file type in a specified directory?

  7. 7

    Copy all excel files from one location to another

  8. 8

    How do I copy all files recursively to a flat directory in Ruby?

  9. 9

    How to copy recursively all files not older than 1 day?

  10. 10

    How to copy "just files" recursively

  11. 11

    How to copy only files in a specified directory to another folder

  12. 12

    Recursively delete all files with a given extension

  13. 13

    recursively display all files with certain extension

  14. 14

    Recursively copy files from one directory to another

  15. 15

    Recursively copy files from one directory to another

  16. 16

    Copy all files recursively without replacing

  17. 17

    How to copy files with a particular extension from one directory to another in linux

  18. 18

    How can I recursively copy files by file extension, preserving directory structure?

  19. 19

    list all the files with the same extension as specified by the user

  20. 20

    How can I recursively delete all files of a specific extension in the current directory?

  21. 21

    How can I recursively delete all files of a specific extension in the current directory?

  22. 22

    AzCopy - how to copy ALL blobs from one storage account to another recursively starting from root$

  23. 23

    How can I recursively copy all pdf files in a directory (and it's subdirectories) into a single output directory?

  24. 24

    How to copy all of the files from one directory to another in a bash script

  25. 25

    How to move all files in dir to another, but copy latest?

  26. 26

    Copy files that partially matches another files in another location

  27. 27

    Linux: Copy all files by extension to single dirrectory

  28. 28

    Recursively execute all files with a specific extension via command line

  29. 29

    Recursively add suffix after extension to all files in a directory

HotTag

Archive