View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Richard Buttrey
 
Posts: n/a
Default Could I use Vlookup?

On Sun, 12 Mar 2006 18:01:10 +0000, Richard Buttrey
wrote:

On Sun, 12 Mar 2006 11:50:42 -0500, Den wrote:

I renamed all my digital and scanned photos but I have applications
that refers to the old names and directories.
I want to replace the old names & directories with the new names and
the new directories for all those jpg file .

On sheet 1, I have in col A, all the new directory & filename
and in Col B, all the old file name only (the old directory is not
there)
There are 1500 lines (pictures) that were renamed. (sorted on col B)

Col A Col B
E:\My PICTURES\2004\20040326_1715.jpg hawai.jpg
E:\My PICTURES\2004\20040326_1698.jpg Kat25.jpg
E:\My PICTURES\2004\20040326_1700.jpg LLLL.jpg
E:\My PICTURES\2004\20040508_1697.jpg L05_0592.JPG

On sheet 2, I copied one of the many txt files of an application where
we can find lines
that refers to the old directory and filename of a picture.

lines...
cell[2].images[0].image=../../../E:\My PICTURES\Fam/Friends\kat25_.jpg
lines...
cell[32].images[0].image=../../../E:\My PICTURES\Fam/Friends\Kito6.jpg
lines...
cell[151].images[0].image=../../../E:\MyPICTURES\Others/cats\IMG_0256.JPG
lines...

I want to replace this old directory and filename
E:/My Pictures/Fam/Friends/kat25_.jpg
with the new directory and filename;
E:\My Pictures\2004\20040326_1698.jpg
but also keep the information that preceded the old filename &
directory.

Final result on sheet 2 should be;
cell[2].images[0].image=../../../E:\My Pictures\2004/20040326_1698.jpg

Any suggestions on a possible solution?

Den


First swap your two columns A & B on sheet 1 over so that the new file
name bcomes the subject value of a Vlookup. (You could probably use
offsets in the Formula below but I think that would unnecessarily
complicate it.

Then on Sheet 2, with your old folder/file names in A1:A..., put the
following in B1 and copy down.

=VLOOKUP((RIGHT(A1,MATCH("\",MID(A1,LEN(A1)-ROW(1:255),1),0))),Sheet1!A2:B5,2,FALSE)

This is an array formula, so enter with CTRL Shift and Enter

I assumed that there was a type above where you said that the second
file name in column B was Kat25.jpg, whereas your old line names
included Kat25_jpg - i.e. with an underscore character.

The '255' number is only there to catch all file names up to 255
characters in length.

HTH
Richard Buttrey
__


Sorry, missed off the front bit which concatenates the
cell[2].images...... bit

This assumes there is only one "\" before the reference to the Drive
"E:" reference. If not please post back.

=LEFT(A1,FIND("\",A1)-3)&VLOOKUP((RIGHT(A1,MATCH("\",MID(A1,LEN(A1)-ROW(1:255),1),0))),Sheet1!A2:B5,2,FALSE)

Rgds


__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________