View Full Version: FolderUpdate

C++ Learning Community > C++ Creations > FolderUpdate


Title: FolderUpdate
Description: Havn't posted here in a while. :)


Ravotus - December 5, 2006 03:53 AM (GMT)
Well, finally, another finished creation by yours truly. It's been a while! :P

This program is simply titled FolderUpdate. You can specify an arbitrary number of source and destination directories, and this program will scan through the destination directories and make sure that all files and optionally folders in the source directories are also in the destination directories. It copies them if they aren't. Recursion into subfolders is optional. It also has the option of allowing the user to pass a regular expression of which files and/or folders are updated.

I originally wrote this program to keep my music folders in sync between my main computer, laptop, and mp3 player.

Source attached below.
For Windows users who don't want to build it or don't have boost, a precompiled Windows binary is available here.

Questions, comments, and suggestions appreciated. :)

C00L - December 5, 2006 05:03 AM (GMT)
Nice creation. ;)

I would have been lazy and just used cygwin/msys + rsync, but your program is easier, leaner and cleaner.

dr voodoo - December 5, 2006 02:25 PM (GMT)
Why do you have a
CODE
po::positional_options_description posOptDesc;

when you don't have any positional options?

Instead of adding default values the way you do:
CODE
vm.count("match") ? vm["match"].as<std::string>() : ".*"

You could also add them to the option description so that the default value will show in --help.
CODE
("match,m",po::value<std::string>()->default_value(".*"),"Only update files whose name matches the specified regular expression.")




Other than that it's pretty good.

Ravotus - December 5, 2006 05:38 PM (GMT)
QUOTE
when you don't have any positional options?

Actually, I do. If you look down a bit you'll see that there are two, the source and destination folder(s). Depending on the option, they can be in different order.

QUOTE
You could also add them to the option description so that the default value will show in --help.

Ok, I will do that when I get home (I'm posting from school).

Thanks for the suggestions. :)

EDIT: Ok, made that change and updated the source and binary.

icon0x - December 6, 2006 02:35 PM (GMT)
nice nice




Hosted for free by InvisionFree