Thursday, September 13, 2012

Print PDF using Adobe Reader from the CMD

To print a PDF from the command line using Adobe Reader you just need to prompt one single command into the CMD

> "C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe" /t "path/file.pdf"

The first part specifies the location of Acrobat Reader (AcroRd32.exe), if you don't know where it actually is installed in your computer you can search for it using Windows search.

The second part is /t and it reefers to printing a file suppressing the print dialogue box.

In the third part, the full path of where is the PDF file we want to print.

More info:
http://livedocs.adobe.com/acrobat_sdk/10/Acrobat10_HTMLHelp/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Acrobat10_SDK_HTMLHelp&file=DevFAQ_UnderstandingSDK.22.31.html

I know this is pretty stupid, but I hope I can do something useful with it and create a batch printing solution.

- victor -

Thursday, August 23, 2012

Backup My Docs with WINDOWS 7 cmd

I just learned how to copy / paste My Documents folder (or any other) to a new folder named Backup+date and I want to share it.

This is the code:
--------------------------------------

@echo off
echo %time%
echo ### creating backup folder
cd C:\Users\victor\desktop 
::md backup_%Date:~-4,4%_%Date:~-10,2%_%Date:~-7,2%

xcopy C:\Users\victor\Documents\* C:\Users\victor\desktop\backup_%Date:~-4,4%_%Date:~-10,2%_%Date:~-7,2% /s /i >> backup_%Date:~-4,4%_%Date:~-10,2%_%Date:~-7,2%.txt


echo Backup Complete!
echo %time%

@pause
-------------------------------------

If you want it, you need to copy this code and paste it in a notepad saving it with a name and with the extension .cmd which is pretty cool because you only need to double click this file to run it, NO need to go to the command line to execute it.

As you can see I mark the time when the script starts and finishes so I know how much time the hole process took.

then I create using "cmd" the backup folder including in its name the date, for now I am just saving the backup folder to the Desktop but really the idea would be creating it directly to an external HDD. I do this because I save a log file with all the doc that were copy from one location to another, but the reality is that xcopy by it self could create the destination folder by pointing the right location.

If you take out the date of the folder then instead of creating multiple backup folders with different dates, you will be overwriting the backup folder which is pretty useful if you only want a single image of your documents.

As you can see it is not rocket science, but I am happy that I was able to do this, now I know that I can write scripts like this for windows to move file around my system.

Vic./

Saturday, June 02, 2012

Compiling a C++ (.cpp) program on the command line of Windows 7 (cmd.exe).


If you are new to this matter like me, and you don't want to use the crap that Microsoft Visual Studio has to offer then follow these simple steps, and you'll be able to write and compile your own programs using notepad or, I strongly recommend using, notepad++. I am writing this because this steps worked well for me in my Windows 7 machine, and I want to keep a record of what I did today and maybe someone one day might read this and find this information useful. 


1.- Download and install MinGw I, downloaded the automated version which is basically an already compiled ready to use .exe (If you like it hard, then you can download the files and compile them your self) from this web page: http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/mingw-get-inst-20120426/ (maybe a new version has been released you I encourage you to check that out).


2.- Download the file and follow the installation instructions, they are not hard to follow. I did the installation of the files directly in my C:\ drive to save some kind of confusion latter on. 


Now you need to specify the path where g++ (which is the compiler I'm going to use) has been installed to the command line (cmd.exe).

3.- Open cmd.exe and type the following and then hit ENTER. 
set PATH=%PATH%;C:\MinGw\bin 
Remember I am using C:\MinGw\bin because that is the location where I installed MinGW, you might have use other one. 


Now you can test if this works by writing a simple C++ program on your notepad.exe and save it as NAME.cpp, in your Documents folder it may be something like:


------------
# include
using namespace std;


int main()
{
cout << "this is stupid";
return 0;
}
------------


Now on the command line (cmd.exe) go to your Documents folder (cd C:\Users\victor\Documents) and see that your file NAME.cpp is actually there by typing DIR (which will show a list of all the files and folders that exist in the Documents folder). 


Now the exiting part: 


COMPILE your file using the following instructions: 


g++.exe "NAME.cpp" -o "NAME.exe"


you will see that an exe file has been created called NAME 
and if you write NAME.exe on the command line it will say "this is stupid"


Well that was it. I hope this has been useful to you as it was for me... 


Regards. 



Tuesday, July 19, 2011

como ejecutar un script de unix como aplicacion desde el Spotlight de mac osx

Lo primero que hice fue hacer un script de Unix (un archivo de texto llamado "archive.sh") que copiara un par de archivos pdf. localizados en mi desktop y los pegara en un folder predeterminado, luego les cambiara el nombre por uno que incluyera la fecha y la hora y despues eliminara los archivos pdf originales en la pasta predeterminada.

el script quedo asi:

-------------------------------------
#!/bin/sh
# GO TO DESKTOP
cd /users/victor/desktop
# COPY AAAAAA AND BBBBBB PDFs TO /published FOLDER
cp AAAAAA.pdf /users/victor/documents/published
cp BBBBBB.pdf /users/victor/documents/published
# GO TO /published FOLDER
cd /users/victor/documents/published
# RENAME cover_letter AND resume PDF WITH TODAY'S DATE
cp AAAAAA.pdf AAAAAA_`date +"%y_%m_%d_%H%M"`.pdf
cp BBBBBB.pdf BBBBBB_`date +"%y_%m_%d_%H%M"`.pdf
# REMOVE ORIGINAL PDF's 
rm victor_carreto-cover_letter.pdf
rm victor_carreto-resume.pdf
-------------------------------------

para poder ejecutar el archivo "archive.sh" desde la terminal use chmod para despues poderlo ejecutar, los comando fueron:

$ chmod u+x archive.sh
$ ./archive.sh

una vez que vi que el escript funcionada desde la terminal decidi que queria poder usarlo con solo apretar command+space que activan el Spotlight de mi Mac y asi no tener que estar usando la terminal todo el tiempo. Asi que use ScriptEditor, para que ejecutara la mismo comando ./archive.sh  que usaba una y otra vez en la terminal; para poder usar el mismo comando utilize "do shell script" que permite ejecutar casi los mismos comandos que desde la terminal.
digo que casi, pues la funcion 'date que utilizo en el script de arriba, no funcionaba en ScriptEditor por causa del simbolo % y fue por eso que el codigo de ScriptEditor manda a ejecutar archive.sh como con los comandos:


do shell script "cd /Users/victor/documents/unixstuff;
./archive.sh"


Este mini codigo lo voy a guardar de dos formas, 1) como script para que si en algun futuro lo quiero modificar tengo el archivo maestro para hacerlo y 2) como una aplicacion, y con esto consigo hacerlo hacerlo ejecutable desde mi Spotlight.  Cabe mencionar que esta applicacion la puedo utilizar en Automator para asi poder crear otras aplicaciones que utilizen este script que se convirtio en aplicacion.