Skip to content

Instantly share code, notes, and snippets.

@jimdiroffii
Created September 14, 2020 15:02
Show Gist options
  • Save jimdiroffii/b36540e851d38bb1fdb03ac27b8edde9 to your computer and use it in GitHub Desktop.
Save jimdiroffii/b36540e851d38bb1fdb03ac27b8edde9 to your computer and use it in GitHub Desktop.
Copy files of a certain type
for /R %%x in (*.jpg,*.png) do copy "%%x" C:\<targetdir>
@jimdiroffii
Copy link
Author

jimdiroffii commented Sep 14, 2020

Alternative, retains subfolder structure: robocopy <searchfolder> <newfolder> /S /COPYALL *.<type>

@jimdiroffii
Copy link
Author

jimdiroffii commented Sep 14, 2020

Alternative, retains subfolder structure: xcopy /s foo\myfolder\*.txt moo\myfolder

@jimdiroffii
Copy link
Author

Alternative, copy files only, without subfolders: Get-ChildItem $source -Recurse | Where-Object { $_.PSIsContained -eq $False } | ForEach-Object {Copy-Item -Path $_.Fullname -Destination $dest -Force}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment