Copy file to several multiple folders - Batch files - file

How can I copy file to multiple folders using batch files.
I success to copy one file to one folder.
Regards,
Ramzy

Like this? Seriously, just add a line for each folder.
copy C:\file.txt C:\dir1\
copy C:\file.txt C:\dir2\
copy C:\file.txt C:\dir3\
copy C:\file.txt C:\dir4\

Yes, this is an old thread, but still, i spotted some code that definitely needs an improvement!
Here is a much better movement code!
copy C:\Folder file is in (Here you can specify certain extension/keyword) C:\destination\
move /-y "SOURCE FOLDER AND DRIVE(specific keyword/extension)*" "DEST FOLDER AND DRIVE"
That way you dont have to write endless lines of code!
-Logan

Related

How to get a real time progress bar for copying a large file (2.2 GB) with a batch file?

I'm making a batch script, but I don't know on how to make a real time progress bar for copying a large file.
Could you help me out?
I'd rather use the standard COPY in batch file, not XCOPY or ROBOCOPY.
My current code is (not all of it):
copy %userprofile%\desktop\target.ipsw %TMP%\downgrade\target.ipsw
The Esentutl /y option allows copyng (single) file files with progress bar like this :
For the sake of your directories, this is what the code will look like:
esentutl /y "%userprofile%\desktop\target.ipsw" /d "%TMP%\downgrade\target.ipsw" /o
Please keep in mind that there are a few limitations to the esentutl command:
You can only copy one file at a time.
The /y syntax was presented in windows vista.
You cannot overwrite files. (You will have to have batch check the destination beforehand and if needed, delete the previous file)

Meaning of . (period) when copying in a batch file

I'm looking through some batch files out of curiosity/for the purpose of learning and I'm seeing one thing I haven't been able to quite make sense of. I'm sure it's something simple, but I don't want to simply run this file, for obvious reasons.
Similar to the following lines:
copy /Y "\git\MyProject\bin\Release\MyLib-1.dll" .
copy /Y "\git\MyProject\bin\Release\MyLib-2.dll" .
copy /Y "\git\MyProject\bin\Release\MyLib-3.dll" .
I know what /Y does from reading online, but what is the . doing? My first assumption was that it meant to copy the file to the current directory, but I was under the impression that's what the %cd% variable is for so I'm not quite sure.
The period refers to the current directory, from which the batch file was called. So, in this case, the 3 DLL library files will be copied to the current directory that called this batch script.
The /Y parameter will force them to be overwritten, if they already exist in the current directory.
It means the current directory, so in your copy-commands it means that you are copying the files to the current directory

Batch file to transfer files with certain phrase in name

I currently use a batch code which transfers files from one place to another. I wish to elaborate on that code to only transfer files which have a certain phrase in their file name.
I did not write the code, and I do not fully understand it but I know what is does.
REM choose desired drive
cd \
Z:
REM change to required directory
cd out
REM cpy all files using * to the desired directory
copy *.dat \\server\f\rug_data\received_transfer
REM delete all files in the folder
REM del *.usr
All I want to do now is add a bit which says only transfer files with 'D0036' in their name.
I have spent time googling but could not find exactly what I was after.
Any help greatly appreciated.
change
copy *.dat \\server\f\rug_data\received_transfer
to
copy *D0036* \\server\f\rug_data\received_transfer
OR, if you mean "All .dat files with D0036 in their name"
copy *D0036*.dat \\server\f\rug_data\received_transfer
* means "match any number of any characters"
Like this?
copy *D0036*.dat \\server\f\rug_data\received_transfer
This works like a charm!
move /-y "C:\(Folder that the contains files)*(Specify a certain character)*" "C:\(Dest Folder)"
This will move everything in the folder with the name that you wrote.
Hope it works!
Logan

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

Renaming multiple files in windows using command prompt?

I have written a small batch file to move files from one folder to another folder.
copy E:\Source\Test.tif E:\Temp
Is there any way can I rename a file name after it has been moved to temp folder.Like
E:\Source:\TestInd1.tiff.
Please suggest.
You can do a move and a rename at the same time, yes:
move someFile S:\ome\Destination\newName

Resources