Search This Blog

Wednesday, March 18, 2009

Folder Duplicator

This script lets you choose a folder and copy it to every subfolder in the chosen destination.

Created it with a specific purpose of updating 200+ Citrix server user folders.

A catalog configuration file for Document Locator had to be placed under c:\documents and settings\username\application data\ColumbiaSoft

I created a folder called Application Data, then ColumbiaSoft under it, and placed the catalog there. Ran the script, selected the new Application Data folder, and chose c:\documents and settings as the destination. The script merged the existing application data with the new one under each username folder. Please pay attention as the script will overwrite existing files without prompting.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    Alex Belenkiy -
    This script will duplicate the source directory into every subfolder of the destination, 
    overwriting existing files in it's path.
    Use with caution!!!
#Include <File.au3>
$Warning = MsgBox(1, "Folder Duplicator", "This application will duplicate the selected" & @CRLF & "source folder into all destination subfolders" & @CRLF & "All existing files will be overwritten")
if $Warning = 2 then Exit
$source = FileSelectFolder("Select Folder to Copy", "")
if @error Then 
    MsgBox(0, "Folder Duplicator", "Invalid Source Folder")
$destination = FileSelectFolder("Select Destination Folder", "")
if @error then 
    MsgBox (0, "Folder Duplicator", "Invalid Destination Folder")
$sourceSplit = StringSplit($source, "\")
If StringRight($destination, 1) <> "\" Then $destination &= "\"
$FileList = _FileListToArray ($destination, "*.*", 2)
if @error then Exit
for $a = 1 to $FileList [0]
    DirCopy ($source, $destination & $FileList[$a] & "\" & $sourceSplit[$sourceSplit[0]], 1)
    if @error then
        MsgBox(0, "Folder Duplicator", "Error encountered while copying folders")
MsgBox(0,"Folder Duplicator", "Done!!!")

No comments: