Help writing batch file for copying/replacing multiple files

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
k@rt
Posts: 2
Joined: 20 Jul 2014 08:03

Help writing batch file for copying/replacing multiple files

#1 Post by k@rt » 20 Jul 2014 08:22

Hello.

I have a very limited knowledge of batch file language and was hoping somebody could give me the commands I would require to achieve the following:

My goal is to remove the ambient sounds from a piece of software, and to achieve this what I must do is replace the 2000 individual .wav files used for the ambient sounds with a single silent .wav file I have made.

So I need a batch file that will either:

Make 2000 copies of the one silent .wav file to a specified location, and then name each of those files using the folder containing the original .wavs as a reference (allowing me to then copy/paste them over)

OR

Go directly to the folder containing the original .wavs, delete each one in turn and replace it with the silent .wav giving it the of the deleted file

Renaming 2000+ files by hand is prohibitively time-consuming so I am really hoping there is some way to do this using batch files.

If anyone would be kind enough to tell me what I need to do, all help would be greatly appreciated. Thanks!!

P.S. The .wav i need to replace all have random names with no sequence or method to the naming, so the names will have to be derived directly from those files in some way

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Help writing batch file for copying/replacing multiple f

#2 Post by foxidrive » 20 Jul 2014 09:00

Assuming the wav files are all in the tree below "d:\base-wav-folder" then this will replace them.


Code: Select all

@echo off
for /r "d:\base-wav-folder" %%a in (*.wav) do copy "c:\folder\silent.wav" "%%a"
pause

k@rt
Posts: 2
Joined: 20 Jul 2014 08:03

Re: Help writing batch file for copying/replacing multiple f

#3 Post by k@rt » 20 Jul 2014 09:24

foxidrive wrote:Assuming the wav files are all in the tree below "d:\base-wav-folder" then this will replace them.


Code: Select all

@echo off
for /r "d:\base-wav-folder" %%a in (*.wav) do copy "c:\folder\silent.wav" "%%a"
pause



Fantastic! Thank you! So this is taking my silent.wav (found at C:\folder\) and repeatedly coping it over all the .wav files in d:\base-wav-folder

Probably best I back up the original folder first then.

Thanks again!!

EDIT: Worked perfectly!! Thanks!! :)

Post Reply