Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Need Batch File to Copy ONE File Then Pause... One File Then Pause

1 view
Skip to first unread message

AlleyCat

unread,
May 1, 2015, 8:47:31 PM5/1/15
to

Possible? I have some very large files to copy from one disk or partition to
others (I'm a backup fanatic), and I don't want the copying process to be
taking the resources while it's copying. Plus, I'd like to defrag the file
after it's copied to the "new" location. I can incorporate that myself, but the
copy of one file, is above my pay grade.

I can do all this overnight, but would like to do it in real-time too.

Any consideration will be most appreciated. Thanks.

JJ

unread,
May 2, 2015, 11:44:17 AM5/2/15
to
If by "not taking resoures", you meant not to take CPU time as much as
possible, then you can start the batch file in another command processor
process as a low priority process using START /LOW. e.g.

@echo off
setlocal
if not "%InLowPriority%" == "" goto start
set InLowPriority=1
start "Backup Batch" /b /low /wait cmd /c %0 %*
goto :eof
:start
rem put backup batch code here
rem
rem e.g.
rem copy sourcefile z:\destfolder
rem contig z:\destfolder\sourcefile

Note that running a process in low priority only make use less CPU
processing share. It doesn't make it use less CPU time. i.e. it'll always
run at full speed whenever the system give CPU time to it.

If you want to make a process use less CPU time and not run at full speed,
you'll have to use third party file copying tools that can limit its file
copying speed. Or a utility that can limit a process CPU usage. e.g. BES but
it can't be automated by command line.

Also be aware that the CPU usage of a file defragmentation process can not
be altered since it is handled separately by the kernel. It always runs at
full speed and can not be limited by tools like BES.

AlleyCat

unread,
May 2, 2015, 9:58:22 PM5/2/15
to

On Sat, 2 May 2015 22:44:09 +0700, JJ says...

AlleyCat

unread,
May 2, 2015, 10:19:35 PM5/2/15
to

On Sat, 2 May 2015 22:44:09 +0700, JJ says...

>
> On Fri, 1 May 2015 19:47:28 -0500, AlleyCat wrote:
> > Possible? I have some very large files to copy from one disk or partition to
> > others (I'm a backup fanatic), and I don't want the copying process to be
> > taking the resources while it's copying. Plus, I'd like to defrag the file
> > after it's copied to the "new" location. I can incorporate that myself, but the
> > copy of one file, is above my pay grade.
> >
> > I can do all this overnight, but would like to do it in real-time too.
> >
> > Any consideration will be most appreciated. Thanks.
>
> If by "not taking resoures", you meant not to take CPU time as much as
> possible, then you can start the batch file in another command processor
> process as a low priority process using START /LOW. e.g.
>
> @echo off
> setlocal
> if not "%InLowPriority%" == "" goto start
> set InLowPriority=1
> start "Backup Batch" /b /low /wait cmd /c %0 %*
> goto :eof
> :start
> rem put backup batch code here
> rem
> rem e.g.
> rem copy sourcefile z:\destfolder
> rem contig z:\destfolder\sourcefile


OK, the "priority" part, I get, but you may have missed the point about wanting
to copy only one file, after xcopy finds it. I'd like it to either pause the
batch file, or stop completely AFTER the file has been found and copied to the
other HDD/partition.

Also, what does the "start "Backup Batch" /b /low /wait cmd /c %0 %*" line do?
We might even forget the priority part altogether, and focus on the xcopy
command line. Is there a way (maybe another "copy" command) that will seek the
files to be copied and stop itself after that one file has been copied.

It sounds impossible. I've got robocopy too, but haven't seen any commands that
will do this.

@echo off
setlocal
if not "%InLowPriority%" == "" goto start
set InLowPriority=1
start "Backup Batch" /b /low /wait cmd /c %0 %*
goto :eof
:start
H:
xcopy /i/s/d/c/y/exclude:D:\download\donotcopy.txt *.* N:\
rem put backup batch code here
rem
rem e.g.
rem copy sourcefile z:\destfolder
rem contig z:\destfolder\sourcefile

Thanks again!

Todd Vargo

unread,
May 3, 2015, 2:06:28 AM5/3/15
to
Type START/? at command prompt for details.

> We might even forget the priority part altogether, and focus on the xcopy
> command line. Is there a way (maybe another "copy" command) that will seek the
> files to be copied and stop itself after that one file has been copied.
>
> It sounds impossible. I've got robocopy too, but haven't seen any commands that
> will do this.
>
> @echo off
> setlocal
> if not "%InLowPriority%" == "" goto start
> set InLowPriority=1
> start "Backup Batch" /b /low /wait cmd /c %0 %*
> goto :eof
> :start
> H:
> xcopy /i/s/d/c/y/exclude:D:\download\donotcopy.txt *.* N:\
> rem put backup batch code here
> rem
> rem e.g.
> rem copy sourcefile z:\destfolder
> rem contig z:\destfolder\sourcefile
>
> Thanks again!
>

Add /L to your xcopy switches and send the output to a file. Then use
FOR/f to parse the file list to copy each file one at a time and delay
between files as needed. Make sure to add the output file to your
donotcopy.txt file.


--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)
0 new messages