3
$\begingroup$

I need to rename a number of files. These are graphic jpg files, and I have an Excel table in which the initial names of these files are collected. For example, this is the name of one of these files taken from the table:

121026_DeviceData\63486504438_Osc.jpg

My problem is that the above name in my Excel file is a hyperlink, rather than a string. By directly addressing this hyperliknk from Mathematica a notebook with a mess inside opens, instead of the desired image. My question is:

How could I clean the text of this file name off from its hyperlink property, such that after the cleaning I get a pure string "121026_DeviceData\63486504438_Osc.jpg" instead of the hyperlink?

Added later: I have found such an approach:

(hyperlinkText/.Hyperlink->String)[[1]]

that returns me a string:

"121026_DeviceData\63486252521_Osc.jpg"

With this the question is answered, though somebody might propose a better solution.

$\endgroup$
3
  • 1
    $\begingroup$ Could you maybe upload a small sample of your Excel table somewhere, for testing purposes? $\endgroup$ Nov 12, 2012 at 12:02
  • $\begingroup$ I have found such an approach: $\endgroup$ Nov 12, 2012 at 12:21
  • $\begingroup$ I do not want to do this, since the table contains lots of things nothing to do with the question. No problem to operate with the table. It easily transforms into the table in Mathematica and can be operated further by the Mathematica methods. Now that I answered the question the rest is trivial. $\endgroup$ Nov 12, 2012 at 12:30

1 Answer 1

5
$\begingroup$

Generating a XLS file for testing purposes:

Export["G:\\stackexchange\\hypli.xls",
{{{Hyperlink["121026_DeviceData\86504438_Osc.jpg", 
    "http://www.somehwere.org/121026_DeviceData/86504438_Osc.jpg"]}}}]

Then

Import["G:\\stackexchange\\hypli.xls"] /. Hyperlink[a_, _] :> a

gives

{{{"121026_DeviceData\\86504438_Osc.jpg"}}}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.