spero di aver capito bene
codice:
var str="c:/cartella1/cartella2/immagine.gif";
var variabile=str.substr(str.lastIndexOf('/')+1);
ciao