Home > Tips 'n' Tricks > How To: Create a Batch file Which will copy all the files from a directory to all the subdirectories

How To: Create a Batch file Which will copy all the files from a directory to all the subdirectories

February 9th, 2010 Leave a comment Go to comments

You all know batch programming, I hope. Its the easiest scripting language for windows. You can just automate so many everyday things in you computer using just batch scripts. Now I am not going into the details where batch programming can help you.

Here I give you the example code for a script which will take a user input for the Directory and copy all the files directly under the specified directory to all the subdirectories. Well you can change the script and make it useful for your own purpose.



so the code for it is:

:input
@ECHO OFF
set INPUT=
set /P INPUT=Input the folder: %=%
cd %INPUT%
for /f “delims=” %%i in (‘dir /ad/s/b’) do for /f “delims=” %%j in (‘dir /aa/b’) do copy “%%j” “%%i”

Categories: Tips 'n' Tricks Tags: ,
  1. SenHu
    February 15th, 2010 at 01:34 | #1

    Nice script.

    You may want to try biterscripting ( http://www.biterscripting.com ) – that’s another scripting language. It may provide more explicit control.

  1. No trackbacks yet.