Hi, I¹m completely new to TM, not a programmer and totally out of my depth on this but here goes!
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? Any help would be really appreciated!
Thanks James
On 6. Oct 2006, at 18:43, thelittleredhen@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!
Alan, Thank you so much for your speedy response. The images are in different places I'll try the second option as you suggest. I don't understand the specific meanings of (.*?) $1 and [^":]+):? with ?$1/? Is there a reference/source where I can learn more about searches and what those expressions mean? Best regards, James
On Friday, October 06, 2006, at 10:15AM, Allan Odgaard throw-away-1@macromates.com wrote:
On 6. Oct 2006, at 18:43, thelittleredhen@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!
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
On 10/6/06, James Mooney thelittleredhen@mac.com wrote:
Alan, Thank you so much for your speedy response. The images are in different places I'll try the second option as you suggest. I don't understand the specific meanings of (.*?) $1 and [^":]+):? with ?$1/? Is there a reference/source where I can learn more about searches and what those expressions mean?
Those are Regular Expressions. You can start here[1]
[1]http://macromates.com/textmate/manual/regular_expressions#regular_expression...