1

I have a folder named Mods and in that folder I have:

  • root\sound\weapons\ak47\ak47_dist.wav
  • root\sound\weapons\m1\m1_dist.wav
  • root\sound\weapons\m4a1\m4a1_dist.wav

etc...

In every ak47, m1, m4a1, etc. folders, I have 5 .WAV sound files.

I want to copy only the *dist.wav named sound files from every "weapon" named folder, and paste these sounds into a single folder with a batch file.

The batch file will be executed from the "Mods" folder which is outside root\sound\weapons, the new folder name is "distant sounds" inside the Mods folder.

How can i do that.

1
  • Please see my answer and let me know if it helped you resolve your issue? If so, feel free to check the little gray check mark to close it. Jul 9, 2016 at 17:48

1 Answer 1

1

How to copy a specific file from sub folders to one other folder

In every ak47, m1, m4a1 etc. folders, I have 5 sounds.

I wan't to copy only the *dist.wav sounds from every weapon folder and paste these sounds to a single folder with batch.

Below is an example of how you can do this from a batch script or from a copy and paste. Please read though everything and test to confirm all works as expected too.

Command Prompt Copy and Paste

SET RootDir=C:\Sound\Weapons
SET CopyDir=C:\Path\Mods\Distant Sounds
IF NOT EXIST "%CopyDir%" MD "%CopyDir%"
SET CopyFname=*dist.wav
FOR /D %A IN ("%RootDir%\*") DO FOR %B IN ("%~A\%CopyFname%") DO ECHO F | XCOPY /Y /F "%~B" "%CopyDir%\"
GOTO EOF 

Batch Script

@ECHO ON
SET RootDir=C:\Sound\Weapons
SET CopyDir=C:\Path\Mods\Distant Sounds
IF NOT EXIST "%CopyDir%" MD "%CopyDir%"
SET CopyFname=*dist.wav
FOR /D %%A IN ("%RootDir%\*") DO FOR %%B IN ("%%~A\%CopyFname%") DO ECHO F | XCOPY /Y /F "%%~B" "%CopyDir%\"
GOTO EOF 

Notes: Set the root directory, the copy directory, and the file name to copy in the SET <variablename>= part of the logic above.

Further Reading and Resources

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .