1.

Solve : Creating Batch File...?

Answer»

Good Afternoon,

I was hoping someone could help. I seem to be struggling setting up a batch file for such a simple command. Basically what I want is 2 folders copying to an external hard drive. Below is what I want

c:/mail signature to E:\Backup
C:/my documents to E:\Backup

Any help would be great

Thanks in advance
Emmaxcopy "C:\My Documents" "E:\Backup\My Documents" /H /E /S /-Y /J
xcopy "C:\Mail Signature" "E:\Backup\Mail Signature" /H /E /S /-Y /J

Ready the 'xcopy /?' to verify all the settings you want are enabled.
Hello,

thanks for responding. One other thing..is there any way of showing a progress bar or percentage of what its copied already?

Regards
EmmaAdd /z to the end. See if that works the way you want it to.Hi Foxidrive, I did that but it DOESNT seem to work........?Sorry, my MISTAKE. It only works across a network, and it doesn't give a total progress bar.Quote from: elj on December 23, 2013, 02:59:50 AM

Hello,

thanks for responding. One other thing..is there any way of showing a progress bar or percentage of what its copied already?

Regards
Emma

if you have exhausted all possible ways, you can do your own progress bar through hardcore programming , or you could search for an already made tool that ties in to copying of files and showing you the progress. In the first place, if you want to see progress bar, it means you are not automating it? so another way is to search for GUI based "xcopy".

to do your own hard core programming in your favourite language.
Code: [Select]filesize = get total file size
somesize = some KB value less than total file size
while true
do
read file with somesize bytes
display progress bar if somesize still less than filesize
sizeleft = filesize - somesize
check to see if all bytes is read from file.
if all read, get out of loop
done
I have no idea about programming unfortunately I wish I did as most things I do would be so much easier....... I think I will leave the progress bar out but I have put echo on so it shows me what files its copying so I'll just stick with that for the time being.

Thanks EVERYONE for all your help.

Happy Christmas

EmmaThis isn't perfect; you won't get a dialog sometimes for a short-time operation e.g. small number of files with no conflicts -

You can use Visual Basic Script to show the Windows copy progress dialog

1. Save this script somewhere with the .vbs extension (e.g. CopyProg.vbs)

Const FOF_CREATEPROGRESSDLG = &H0&
strSourceFileSpec = wscript.arguments(0)
strTargetFolder = wscript.arguments(1)
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(strTargetFolder)
objFolder.CopyHere strSourceFileSpec, FOF_CREATEPROGRESSDLG

Call it from a batch like this

1. To copy all files and subfolders from the folder C:\My Documents to the folder D:\Targetfolder (which MUST already exist)

Note: On my system I need the \*.* after the source folder

wscript "c:\scripts\CopyProg.vbs" "C:\My Documents\*.*" "D:\Targetfolder"

2. To copy one file from one place to another

wscript "c:\scripts\CopyProg.vbs" "C:\batch\addup.cmd" "D:\batch"

Remarks: You may find you only get a dialog for a long operation or if target files already exist; for one or a few small files from one local hard drive to another the copy happens too quickly; if target files already exist you will be asked for skip/overwrite/rename options.

You don't need to include the full vbs file path if it is in the same folder as the batch script.

Tested on Windows 7

Alternative: install something like Teracopy and study the command line options (may not be an option in a workplace computer) (You can make Teracopy replace the Windows file copy dialog)

CopyProg.vbs syntax:

[cscript|wscript] Copyprog.vbs [move|copy] source dest flags

If no flags specified, there is a dialog for non-instant operations, and all file replace/overwrite options are presented to the user, in a dialog with a "Cancel" button.

Use quotes around source and dest if they have spaces.

Flags:

4 Don't display a progress box
8 Rename if target file already exists
16 Respond with "Yes to All "for any dialog box
64 Preserve undo information, if possible
128 Operate on files only if *.* is specified
256 Display a progress dialog but do not show file names
512 Don't confirm creation of new directory
1024 Don't display a user interface if an error occurs
2048 Don't copy security attributes
4096 Local directory only (no recursion)
8192 Only copy the specified files

Examples:
Wscript CopyProg.vbs copy "c:\batch" "D:\batch" 8 16 512
Cscript CopyProg.vbs move "d:\copysource\batch\001-999.txt" "E:\test"

Code: [Select]iFlags = 0
For j = 3 to (wscript.arguments.count)-1
iFlags = iFlags + Cint(wscript.arguments(j))
Next
strSourceFileSpec = wscript.arguments(1)
strTargetFolder = wscript.arguments(2)
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(strTargetFolder)
If lcase(wscript.arguments(0)) = "copy" Then
objFolder.CopyHere strSourceFileSpec, iFlags
End If
If lcase(wscript.arguments(0)) = "move" Then
objFolder.MoveHere strSourceFileSpec, iFlags
End If








Discussion

No Comment Found