Showing posts with label scripts. Show all posts
Showing posts with label scripts. Show all posts

Thursday, October 3, 2013

Picasa: Renaming File Names to Picasa Captions

Some 5 years back, I wrote on this blog on how to set the caption of a image as it file name. In those days, I used to change the filename first and then set the caption for picasa. Now things have moved online and today I set the caption first is Google + (which did not exist then) and then downloaded the album to my local picasa and tried to rename the file. How to do it?

With some Windows commandline revision and use of Exiv2 I was able to achieve it. So here it goes.
  1. I assume that you have downloaded the picasa web album to a local folder using picasa.
  2. Open command window and type in :
    forfiles /C "cmd /c ..\exiv2 -g Exif.File name -g Iptc.Application2.Caption  -Pv @file" > files.txt
  3. This will create a file "files.txt which will look like :
    100.jpg             1. My caption
    where the 1st column is the File Name and the 2nd column is the given caption.
  4. Open the files.txt in Notepad++ and edit it. Replace the huge space between the filename and caption with some deliminator like ';'. The result should look like:
    100.jpg;1. My caption
  5. Now in the command window type in:
    for /f "tokens=1,2  delims=;" %i in (files.txt) do ren "%i" "%j.jpg"
    This will take the filename as the first token and caption as the 2nd token as we have used the deliminator ';' and then do a rename. Note that I have use %j.jpg" to give it the correct extension.
  6. And the job is done :)

Saturday, November 8, 2008

Remotely Shutdown / Reboot your Windows Box

A lot of time, I need to restart a windows server. Earlier I used to make a remote desktop connection to the server which easily took over a minute or two as its a server and logged me to a domain. Then I used to restart it from the gui.

Now I found a way to restart it from my local desktop. The command goes like

shutdown -m \\ -r

where -m is used to specify the machine name and -r is meant to specify that the machine needs to be rebooted.

Then I check for the actual reboot by

ping -t

I see that it gets ping messages back, and then stops responding for some 8-10 pings and then gets back up again.

Now this really saves me a lot of time :)

Wednesday, October 1, 2008

Picasa: Adding File Names to Caption - Update

In my earlier post on Picasa: Adding File Names to Caption, I got a request from Peter, who requested the script to be modified to:
"Do you know of a way to make it go through sub directories, or do I need to copy the script and program to each directory along the way."

This can be achieved easily by making the for loop recurse through directories so the new script will look like:

FOR /R %c in (*.jpg) DO exiv2 -k -M "set Iptc.Application2.Caption %~nc" "%c"

This would solve the directory recursion issue.

There is a second issue mentioned by mectas which can be easily solved by putting the exiv2.exe in the same folder where the pictures are or place it at c:\Windows which is by default added to your path.

Thursday, January 17, 2008

Picasa: Download Web Albums in Firefox or Opera

Update of this post taking care of new Picasa release is explained at http://sandyiit.blogspot.com/2008/09/picasa-30-download-web-albums-in.html

I am slowly turning into a google consumer. When I first ventured into the world wide web, it was dominated by Yahoo. I used Yahoo search and later moved to google search. I used Yahoo mail which I later switched to gmail. I user Yahoo messenger and later switched to GTalk. I used Yahoo pics and also Flickr. I liked flickr but its 200 pics limit was something which irritated me. So when I saw picasa giving a Gig of space for my pics I moved to it. So I am moving out of Yahoo's fold to Google's. Its not that Yahoo is bad but they make things heavy and bloated. Google keeps it simple and tidy which I like and hence so many changes.

Photos is one service where I still love flickr compared to picasa but I still use picasa because of it 1 Gig space and also its desktop application which lets you do quite a lot of things. Still it has its impairments. In my last post I talked about caption, now its time for downloading whole web albums present in picasa web.

Picasa has its own protocol picasa:// to download and upload pictures from desktop to the web. Ideally when you install picasa on your desktop, this protocol should get registered to your web browser which should tell the browser that if such a link appears what to do which is to launch picasa. Sadly only IE seems to understand it and work as expected. Neither Firefox nor Opera seems to understand the protocol and hence it shows a "Download Picasa" link
in the left navigation menu when Picasa is already installed on the desktop. Now how can we
download the whole album?

To do so, just view the source of the page. Do a right click + View Page Source in case of Firefox of press CTRL + F3 in case of opera. Now in the HTML source search for the string picasa://.

Now you will get a statment which looks like:

picasa://downloadfeed/?url=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fback_compat%2Fuser%2Fsandyiit%2Falbumid%2F5152729459149591681%3Fkind%3Dphoto%26alt%3Drss%26imgdl%3D1


This is the download url based on the picasa:// protocol. Now how do you use it to download the album. Simple, just open the command window type in:

> c:\Program Files\Picasa2\Picasa2.exe _url_

The _url_ is the picasa:// url which we got above. When you do so, you will picasa launching itself and loading the web album and asking you whether you want to download it or not. Do it and you have the album at your desktop and the work is done :)

Monday, January 7, 2008

Picasa: Adding File Names to Caption

Update of this post is available at http://sandyiit.blogspot.com/2008/10/picasa-adding-file-names-to-caption.html

I used to save my pictures in photos@yahoo then moved to flickr. Flickr was good but had a limit of 200 pics per account. So had to move on to the google belt and started using picasa. There was 1 GB up for grabs so I started uploading my pictures to it.

I faced a problem. Normally when I transferred my pictures from my camera to my laptop, I got names like Picture 001.jpg, Picture 002.jpg. So I renamed them to names like 001. The start.jpg which conveyed more information and added to its memory value. Then I uploaded them to picasa to see that none to the names appear in there. Picasa uses IPTC tags to display captions.

Searching in the net, I found the tag was Iptc.Application2.Caption and this post provides nice information to set the captions equal to your filenames but the script

FOR %%c in (*.jpg) DO exiv2 -k -M"add Iptc.Application2.Caption %%c" "%%c"

has a issue. It takes filenames hence appends the extension .JPG to the caption too. Next it tries to add the IPTC tag which if already set, new caption can't be added. We need to force it or simply overwrite it. So I changed the script to

FOR %%c in (*.jpg) DO exiv2 -k -M"set Iptc.Application2.Caption %%~nc" "%%c"

This now sets hence overwrites the Caption tag and also takes the filename without the extension as the caption and thats what I wanted.

P.S: I got a comment:

Barun said...
Sonique/ Sandeep- I tried running the command given by sunil25125 by extracting exiv2-o.18 and making the nmtocap.dat, both in the same directory as my jpg files. But when I double click on the .dat file, I get following errors for each file:
Failed to Open the File

Any way out?

Thanks


And the answer is.

Windows shell might see some problems with the above script specifically the variable declared as %%c. Please try %c is that case specially when you get "Failed to Open the File" . So the script for you will be:

FOR %c in (*.jpg) DO exiv2.exe -k -M"set Iptc.Application2.Caption %~nc" "%c"