1.

Solve : xml file rename problem?

Answer»

I have to rename a image file based on an xml file. Here is the xml.



sales
abc company
lexmark_Jun_23_2011_15_27_40_504.tif


so the image file would be
c:\scans\lexmark_Jun_23_2011_15_27_40_504.tif

The XML and image file are in the same folder.
I want to end up with "sales_abc company.tif" and have the orginal tif and xml deleted

Can you help? I was going to GO to php but say another post where you did it with VB so I thought I would ask.Code: [Select]@echo off
set xmlfile=test.xml
for /f "tokens=1-2 delims=^<^>" %%A in ( ' type %xmlfile% ^| find "imagefile" ' ) do set imagename=%%B
ren "%imagename%" "sales_abc company.tif"
del "%xmlfile%"

So Bill has graduated from just being a damned nuisance to poisoning threads with malicious "code". Please ignore the troll. His post contains an attempt at SABOTAGE. This line would obliterate the image file!

Code: [Select]echo hello > %imagename%
I sure hope the OP does not act upon any PM he may have received.



Posts removed.
Sorry didn't catch it sooner Salmon...

patio.Quote from: patio on June 25, 2011, 12:54:58 PM

Posts removed.
Sorry didn't catch it sooner Salmon...

patio.

Never mind... it enlivened the thread a bit...
The script I posted above will correctly process the xml file posted by the OP to isolate the TIF filename. It then proceeds to rename the TIF, and delete the xml file, which, as the OP says...

Quote
are in the same folder.

I have tested this with an actual TIF from my scanned images folder. It works. It would work with any arbitrarily named file.

Since a certain troll INSISTS on polluting this thread, I am disabling notification of replies to avoid recurrent annoyance from this character.



This might be a BAD time to point out that I don't like your poetry.Quote from: BC_Programmer on June 27, 2011, 12:46:22 PM
This might be a bad time to point out that I don't like your poetry.

Did you mean me? Or the idiot?
Quote from: Salmon Trout on June 27, 2011, 01:10:31 PM
Did you mean me? Or the idiot?
The latter of course. You mean you haven't read my poetry?

I'll go out on a limb here and guess bill ain't real good at poetry...A good idea to lock this thread?
done


Discussion

No Comment Found