Cross-Platform Scripts to Create Time/Date Stamped Versions of Your Files For Collaborative Work (with GUI options!)
Summary: A set of scripts (one for *nix and OS X, one for Windows) that create a time-date stamped copy of any file from the commandline. Lots of comments in the code and the option of using Zenity or Java-based Wenity if you need a point-and-click GUI to choose the file. The scripts are on GitHub at https://gist.github.com/4083393.
When you're working with other people, it's often necessary to trade files back and forth as you make revisions. Unfortunately, even with "track changes", you often lose track of which copy of a file each person has. Yes, you can invest the time and energy to learn git for versioning your writing projects, but even streamlined projects like Flashbake have a high learning curve.
I've had people send me three different versions of the same file, all with the same filename within the course of a day. It happens, it's part of business, but it was hard for me to make sure I had the right one.
I've seen people try altering the filename by lots of ways, but the only way that's made sense to me is this:
That's how I deliver versions of eBooks to people who hire me to convert their text to ePub or Kindle. That way they know that MyAwesomeBook_20121114_2359.epub is an earlier version than MyAwesomeBook_20121115_0001.epub.
I realized that this kind of thing needs to be more widespread, crossplatform, and easy.
So let me introduce you to my versioning scripts. They're scripts (bash for *nix and OS X, batch file for Windows) that you can use to create versions of any file. It will make a copy of the original file with the date and time tacked onto the end as I demonstrated above. I've written a version for *nix (which should also work on OS X) and a version for Windows XP and up. There's a commandline interface, and also hooks for it to work with one of two point-and-click GUI (graphical user interface) programs.
It's pretty simple to use.
*nix and OS X:
bash version.sh YOURFILENAME
bash version.sh YOURFILENAME
If you're running it from a different directory than where YOURFILENAME resides, input the full path. Otherwise you don't have to. Run it without any arguments for a quick description of what it does. For *nix and OS X, you have the option of the -s switch to follow a symlink and alter the file it's linked to.
Don't care about the GUI? Dive right into the scripts at GitHub here: https://gist.github.com/4083393.
If you want to use GUI, your two options are Zenity and Wenity. To run it with the GUI, simply make a shortcut or launcher that calls it with the -z switch for Zenity and the -w switch for Wenity. Windows users, use /z and /w instead of -z and -w.
If you use the GUI switches, the script tries to find Zenity or Wenity and Java on its own, but you should probably edit the script to tell it where the executable files reside. Don't worry about changing any lines for things you don't use, though. It'll do just fine.
Zenity for *nix: https://live.gnome.org/Zenity
OS X: Zenity through MacPorts with this command: sudo port install zenity
Windows port of Zenity: http://www.placella.com/software/zenity/
Get Wenity (uses Java for *nix, OS X, and Windows) here: http://kksw.zzl.org/wenity.html
If you use Wenity, you'll need Java: http://www.java.com/getjava/
The scripts each have LOTS of comments to help guide you through everything, and hopefully will be of some use if you are just picking up how to write scripts in bash or windows batch files (which are actually MUCH harder). They're also under a CC-BY-SA license, so feel free to use, adapt, and share them.
The scripts are hosted on GitHub right here: https://gist.github.com/4083393
I hope you find them as useful as I do!
- If you're not using bash (type echo $SHELL in your terminal to find out) just alter the first line in the file. It should work as-is with zsh. If you run another shell and can let me know if it works, that'd be awesome.
- I've not full-on tested the GUI on Windows and OS X - but it should work okay. Let me know if you run into problems.
- Wenity's example files have some problems and issues, especially for the file selection dialog. They're fixed here; I let the author know.