Thread:Project:Support desk/Upload Files with command line/reply

The maintenance script importImages.php was written exactly for this purpose. See Manual:ImportImages.php, especially the --overwrite parameter!