Batch Scripts, the more I love them, the more I hate them. I only started using them about a year ago, but soon found out how handy they can be at times.
Actually coding a Windows Batch Script is a real pain in the neck, the language syntax is really primitive and doesn’t make much sense (one point for Linux on this subject), so much that, oftentimes, I’d rather write a small Java app, or C#, or maybe even something with Visual Basic 6.
But I’ve grown really fond of these little .bat files, that needn’t be compiled at all, and are extremely portable (under the Windows platform), and can be modified to suit your needs in a second.
Anyhow, here’s p4ftp.bat, a little Windows Batch Script to upload a Perforce change list from console to a FTP host. You just need to set the constants for ftp host, username, password, the path to your workspace, and the depot name.
You can call this script from console passing the cl as the first argument, for example:
Even better, you can set it to from the Perforce Visual Client (P4V) like this:
Menu > Tools > Manage Custom Tools...
New > Tool
Application: <path to p4ftp.bat>
Arguments: %C 1
And now, all you have to do is right click on the changelist (whether pending or submitted), and click “p4ftp” to upload it.
You can view the source code and download it here. The script has several limitations, but it can be adapted however you wish.
Oh, and if you found this script useful, or made a new version, I’d love you to comment about it :)
See you in the next post!