powershell - Copying Multiple files with specific extension -


so have little problem...

(windows 10 education n x64)

i goldsrc engine developer , trying achieve following thing batch script or powershell, automated task instead of me manually picking every damn folder, spare time. :)

i having directory structure following:

main(root) folder names "goldsrc" located @ "desktop"

so goes this:

absolute path:

image tree view:

image tree view

[main folder] c:\users\andrej poženel\desktop\goldsrc  [source directory copy recursive subdirectories] c:\users\andrej poženel\desktop\goldsrc\prefabs  [directory copy to] c:\users\andrej poženel\desktop\goldsrc\maps 

i want lookup subfolder named "prefabs" , search subfolders in directory files have file extension .map , .rmf, both filters , copy them source location [../goldsrc/prefabs/like_100_folders_here] "goldsrc" subdirectory named "maps", shown on picture)

so want things after process:

c:\users\myusername\desktop\goldsrc\maps: blabla.map bleble.rmf bleble.rmf cacac.rmf adasdad.map ...

and not each file in own directory in source dir...

thanks in advance

pushd "c:\users\myusername\desktop\goldsrc" /f "delims=" %%a in ('dir /s /b /a-d .\prefabs\*.map .\prefabs\*.rmf')  echo copy "%%a" ".\maps\" popd 

should execute this.

first move required subdirectory, perform directory scan including subdirectories in basic form , excluding directorynames. each returned line matching either of filespecs, assign name found %%a, copy file required subdirectory.

then return original directory.

the commands generated echoed console. execute command (after checking), remove echo keyword.

note batch file, , not intended executed directly prompt.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -