[TxMt] Find, convert and replace image paths
Allan Odgaard
throw-away-1 at macromates.com
Fri Oct 6 17:14:14 UTC 2006
On 6. Oct 2006, at 18:43, <thelittleredhen at mac.com> wrote:
> I have an xml file that contains numerous image paths in this
> format <Pic_path href="HD2:Working Files:images:testpic.jpg"/>
>
> I need to convert them to this format <Pic_path href="file:///
> Volumes/HD2/Working Files/images/testpic.jpg"/>
>
> Is there any way I can get TM to search for the paths and convert
> the text?
If all the images are in the same location, you can enable Regular
Expressions, then search for: ‘<Pic_path href="HD2:Working
Files:images:(.*?)"/>’ and replace with: ‘<Pic_path href="file:///
Volumes/HD2/Working Files/images/$1"/>’.
If however they vary in path, you will need to first do a replace
from: ‘<Pic_path href="HD2:’ to ‘<Pic_path href="file:///Volumes/HD2/’.
Then repeat a (regular expression) replace of: ‘(<Pic_path
href="file:///Volumes/HD2/[^":]+):’ with ‘$1/’ until no replacements
are done.
Do a backup first!
More information about the textmate
mailing list