Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
1  
Could you maybe upload a small sample of your Excel table somewhere, for testing purposes? –  J. M. Nov 12 '12 at 12:02
    
I have found such an approach: –  Alexei Boulbitch Nov 12 '12 at 12:21
    
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. –  Alexei Boulbitch Nov 12 '12 at 12:30
add comment

1 Answer 1

up vote 4 down vote accepted

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"}}}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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