batch file for copying users profile data to a network drive

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
loco
Posts: 3
Joined: 12 Mar 2021 07:30

batch file for copying users profile data to a network drive

#1 Post by loco » 12 Mar 2021 07:55

Hey Guys,
I am a novice to creating batch files and would be grateful for some assistance in getting one
which copies all the users profile data to a network drive (i) in this case.
I would also like there to be a some kind of progress bar indicating the status of the copying.
Really appreciate some help with this.. :?: :idea: :)
loco

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: batch file for copying users profile data to a network drive

#2 Post by Squashman » 12 Mar 2021 09:18

I would take a look at the Robocopy command.

loco
Posts: 3
Joined: 12 Mar 2021 07:30

Re: batch file for copying users profile data to a network drive

#3 Post by loco » 12 Mar 2021 11:25

@Squashman , thanks man

I think I found something decent that should take care of it. But there's a bit more than just the below that I also need to add.
Let's say I also needed to add something which first performs a check on the size of all the files and if they are for example bigger than 5gig
then select a move to onedrive instead, any ideas on how I would go about it. Appreciate any help on this...

@ECHO OFF
SETLOCAL
SET DEST=\\servername\i$\Users\%USERNAME%
ROBOCOPY /MIR /XJ %USERPROFILE%\Documents %DEST%\Documents
ROBOCOPY /MIR /XJ %USERPROFILE%\Desktop %DEST%\Desktop
ROBOCOPY /MIR /XJ %USERPROFILE%\Favorites %DEST%\Favorites
ROBOCOPY /MIR /XJ %USERPROFILE%\Downloads %DEST%\Downloads
ROBOCOPY /MIR /XJ %USERPROFILE%\Appdata %DEST%\Appdata

KR
loco

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: batch file for copying users profile data to a network drive

#4 Post by Squashman » 12 Mar 2021 11:30

loco wrote:
12 Mar 2021 11:25
Let's say I also needed to add something which first performs a check on the size of all the files and if they are for example bigger than 5gig
then select a move to onedrive instead, any ideas on how I would go about it.
Did you miss reading this in the help file for Robocopy?

Code: Select all

/MAX:n :: MAXimum file size - exclude files bigger than n bytes.
/MIN:n :: MINimum file size - exclude files smaller than n bytes.

loco
Posts: 3
Joined: 12 Mar 2021 07:30

Re: batch file for copying users profile data to a network drive

#5 Post by loco » 12 Mar 2021 11:35

I'll have another look and see if I can figure it out, thanks again.

Post Reply