the Copy commond with “-include”

Welcome Forums General PowerShell Q&A the Copy commond with “-include”

Viewing 4 reply threads
  • Author
    Posts
    • #218355
      Participant
      Topics: 1
      Replies: 1
      Points: 18
      Rank: Member

      while my command like this:

      Copy-Item ‘C:\trans\*’-Include ‘*.flv’ -Destination ‘C:\test\’ -Recurse -Force

      but it does not work

      while i change the “-include” into “-exclude” it really work ;

      I don’t know why

    • #218376
      Participant
      Topics: 4
      Replies: 2247
      Points: 5,484
      Helping Hand
      Rank: Community MVP

      Inaho, welcome to Powershell.org. Please take a moment and read the very first post on top of the list of this forum: Read Me Before Posting! You’ll be Glad You Did!.

      When you post code or error messages or sample data or console output format it as code using the code tags “PRE“, please. Thanks in advance.

      What exactly do you mean with:

      … does not work

      What is in your source directory and what would you expect to happen? You could try the parameter -Filter instead.

      Copy-Item 'C:\trans\*' -Filter '*.flv' -Destination 'C:\test\' -Recurse -Force
    • #218478
      js
      Participant
      Topics: 29
      Replies: 813
      Points: 2,450
      Helping Hand
      Rank: Community Hero

      What’s the error message? It works for me, as long as the source path has a wildcard. Only .flv files are copied.

      • This reply was modified 1 month, 2 weeks ago by js.
    • #218745
      Participant
      Topics: 1
      Replies: 1
      Points: 18
      Rank: Member

      I did this ,but nothing has be copied still.

    • #218787
      Participant
      Topics: 4
      Replies: 2247
      Points: 5,484
      Helping Hand
      Rank: Community MVP

      What happens when you use Get-ChildItem with the parameter you use for Copy-Item?

      Get-ChildItem -Path 'C:\trans\*' -Include '*.flv' -Recurse

      You might try it with the parameter -Filter as well …

      Get-ChildItem -Path 'C:\trans\*' -Filter '*.flv' -Recurse
Viewing 4 reply threads
  • You must be logged in to reply to this topic.