Saturday, February 15, 2014

Quick & useful batch files

Just want to share two quick and useful batch file (scripts) I've found useful.

Ever download a useful PDF book but found out it's "SECURED" and you can't print or make any markups/highlights? For instance I'm fond of the PWC Indonesian Pocket Tax Book, but I want to highlight important sections, dangit.  Install Ghostscript and use this simple batch file and you can get rid of this "SECURED" garbage in no time.

I'm too lazy to set up a good backup system, but every other month I would save my 50+ gigabyte PROJECTS folder to a portable HD (which I only hook up for this very purpose).  Robocopy is a simple command-line utility, included in all versions of Windows since Vista, that lets me create duplicate of the PROJECTS folder into the HD.  It does incremental backups (i.e. if a file/folder is unchanged, it doesn't waste time recopying), and also gets rid of empty folders.  
TIP: If you set the target folder in your portable HD as "compressed" before you run Robocopy, then you can save around 10% of disk space.  Which may not sound like much, but these things add up.

The syntax for the batch files are quite self-explanatory. You'll need to adjust the file names/paths though, including your Ghostscript version if it's not the same

@if "%1"=="" echo You need to insert a filename as parameter
"C:\program files\gs\gs9.10\bin\gswin64c.exe" -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pdfwrite  -sFONTPATH=%windir%/fonts;xfonts;. -sPDFPassword= -dPDFSETTINGS=/prepress -dPassThroughJPEGImages=true -sOutputFile=output_100.pdf  "%1"

@echo pls remember to map \\server_ip\server_folder to S: drive !!!
robocopy D:\PROJECTS S:\PROJECTS /S /PURGE /TEE /UNILOG:robocp_Projects_log.log

No comments: