Batch file to copy folder to multiple network destinations - file

I have been able to copy files from 1 location to another using the batch file.
However I need to copy the complete folder from one server to multiple servers.
Example;
Local machine name :
LOCAL
Destination machines :
Network1
Network2
folder that i need to copy
Local\d:\Hello
The whole folder hello and its contents to be copied
to
Network1\c
Network2\c
So the folders thats created should be like (with all the file within)
Network1\c:\Hello
Network2\c:\Hello

Looks like you might want to use xcopy. See below;
batch/bat to copy folder and content at once
You should end up with a script like this;
xcopy d:\Hello \\Network1\c$\ /E
xcopy d:\Hello \\Network2\c$\ /E

Related

Copy folder to destination with its folder structure

I have a folder foldertocopy with files in it. It is inside a folder structure like so
D:\somefolder1
|--somefolder2
|--somefolder3
|--foldertocopy
There could be other files or folders in any of the folders above. I have a destination folder like so E:\destinationfolder
I want to copy foldertocopy along with its contents to destinationfolder with the folder structure of foldertocopy till the parent somefolder2 so that at the end of copy it looks like so
E:\destinationfolder
|--somefolder2
|--somefolder3
|--foldertocopy
I don't want any of the other files or folders to get copied. How do I go about it?
I have tried robocopy in Windows 10, but I am not able to get the command right.
robocopy "D:\somefolder1\somefolder2\somefolder3\foldertocopy" "E:\destinationfolder" /E /LEV:3
All it does is, copy all the contents of foldertocopy to E:\destinationfolder, without any folder structure.

Batch - Extract many zip, rename files extracted in a same directory

Hi, I have many zip files located at g:\toto. These zips contain some files. I would like to extract all zip in a same directory (g:\toto\extracted) then rename various files of the zip.
Example 1 :
www_12567.vp.zip : 3 files : alpha.doc, beta.xls, teta.doc
I would like after extraction, files are renamed with the name of the zip
www_12567.vp.alpha.doc, www_12567.vp.beta.xls, www_12567.vp.teta.doc
Example 2 :
www_12.vp.zip : 3 files : al.doc, bea.xls, tta.doc
www_12.vp.al.doc, www_12.vp.bea.xls, www_12.vp.tta.doc
I found this question, but it talks about .txt and the zip contain one file, so, it doesn't work.
Without knowing the contents of the archive you can't know which files to rename, because you are putting them into a directory that may already contain other files.
This, however, would be much easier if there was a dedicated directory to put the files temporarily. Here's how you could use it:
#ECHO OFF
SET "srcdir=G:\toto"
SET "tgtdir=G:\toto\extracted"
SET "tmpdir=G:\toto\extracted-tmp"
FOR %%Z IN ("%srcdir%\*.zip") DO (
unpack "%%Z" with your favourite tool into "%tmpdir%"
FOR %%I IN ("%tmpdir%\*") DO MOVE "%%I" "%tgtdir%\%%~nZ.%%~nxI"
)
Of course, the temporary directory would need to be empty before running the batch file. You could add DEL "%tmpdir%\*" somewhere before the loop to make sure it is.
One other note is, the above assumes that the archives do not contain subdirectories or, at least, that the files are extracted without subdirectories.
UPDATE
If you are using the 7-Zip archiver to work with .zip files, then this is how your extract command might look:
7z e "%%Z" -o"%tmpdir%"
Disclaimer: I'm not an active user of 7-Zip. This is what I used as a reference to come up with the above command:
7-Zip Command-Line Examples

Hey, i need help in batch to make it copy everything in 1 folder to another folder

im working on a script that have few folders and i don't really understand how to make an config for this but i don't need it.
i have setup a script config inside
Set cfg=cfg2
Set txt=txt2
Set rar=rar2
cfg2, txt2, rar2 are in a diffrent directory
the files in cfg are cfg files but theres alot of them.
this also goes for txt & rar too.
i want a copy script that copies all cfg files (and only cfg files) into the cfg2 file that are in another directory.
and then this goes again for the txt & rar files.
I also know the code for move but i really want to copy it
cause on move you just do
move "txt/*.txt" %txt% and thats kinda what i want to do but that aint working
Have a look at robocopy from microsoft.
Something like the below should work;
robocopy /s \path\cfg \path\cfg2 *.cfg

Need to copy and rename files in different folders

would anyone know how to write a batch file (or two) that would:
copy hundreds of "index.html" files that are in different folders and keep within the same folder (so needs to search within sub folders)
rename the copies (keep the originals as is) to "index.jpg"
could anyone help?
I used a bulk rename tool to rename all index.html files to index.jpg in a copy of the main folder, then used robocopy to copy everything over, including the file structure back to the original folder (leaving the index.html's alone)

seting up a template folder copy/ past system with batch

I have a foldering system setup consisting of a “master folder” wich varys in name holds two sub folders, the sub folders though are always called CTB and DWG. I want the contents. of the DWG folder always to be coppied to the desktop and the contents of the CTB to always be coppied to C:\ICT\Autocad_2010\CTB. Remembering that the master folder varys in name pending on the project.
Is this possible with batch?
somthing like:
XCOPY %0\DWG\*.* c:\ICT\AutoCAD_2010\CTB
Nevermind i got it
XCOPY "%cd%\DWG\*.DWG" c:\
however how do i copy it to the desktop?
try this to copy to the current user desktop
xcopy "dwg\*.dwg" "%Homedrive%%Homepath%\desktop"
or this to copy to all users desktop
xcopy "dwg\*.dwg" "%allusersprofile%\desktop"

Resources