A Little project backing up folders

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Stevo
Posts: 2
Joined: 24 Jan 2019 15:37

A Little project backing up folders

#1 Post by Stevo » 24 Jan 2019 16:46

Hello everyone,

I have just discovered this forum. I have written the odd trivial batch file, nothing sophisticated. My current task is to back up my Music folder on to four USB thumb drives that individually are smaller than the music collection. My pseudo code is below. Please comment on weather this is a reasonable approach given the functionality available in batch programming. Currently I have no clue how to implement this but it's easy to find out with a bit of research.

batch file runs inside Music Folder
treat folders in alphanumeric order

Variable = the folder being copied
copy Variable to F:
exit loop if F: runs out of space
increment Variable to next folder
Loop back to "copy Variable to F:"

Delete Variable from F:
REM last attempt will be a partially copied folder

copy Variable to G:
exit loop if G: runs out of space
increment Variable to next folder
Loop back to "copy Variable to G":

Delete Variable from G:
REM last attempt will be a partially copied folder

copy Variable to H:
exit loop if H: runs out of space
increment Variable to next folder
Loop back to "copy Variable to H":

Delete Variable from H:
REM last attempt will be a partially copied folder

copy Variable to I:
exit loop if I: runs out of space
increment Variable to next folder
exit loop if we run out of folders
Loop back to "copy Variable to G":

Exit

pieh-ejdsch
Posts: 192
Joined: 04 Mar 2014 11:14
Location: germany

Re: A Little project backing up folders

#2 Post by pieh-ejdsch » 25 Jan 2019 12:55

Hello Stevo,

I once had a similar requirement, with just a backup should be divided into several media.
Maybe this can help you here.
Please test it and let me know.
If you need it I can provide an English version.
https://administrator.de/forum/robocopy ... ent-780547

Phil

Stevo
Posts: 2
Joined: 24 Jan 2019 15:37

Re: A Little project backing up folders

#3 Post by Stevo » 29 Jan 2019 03:11

Thanks Phil,

That is a comprehensive script. Unfortunately far beyond my understanding. I was going to start simply and build up. Perhaps you can assist with this.

ECHO OFF

FOR /f "delims=" %%a in (list.txt) do (
ECHO %%a
SET /p var= %%a

ECHO:%var%

robocopy "%var%" F:"%var%"

)

This has two problems. It requires an enter key stroke to manually continue the loop and robocopy only works when the directories listed in list.txt have no spaces.

Post Reply