Page 1 of 1

Take only Dependent or related file and folders

Posted: 21 Mar 2013 19:16
by shamsudeen
Hi all,

I work in web designing and editing the HTML files. In a project folder there will be more than
10 files and several folder will be there, when I copy a a HTML files to another folder out of this project folder, I have to copy all folder and images so the size of the folders becomes high. Here is my question how to copy the files and folders which is related to this one html file to another location, i.e. which is linked or embedded to this HTML only.

When I copy a HTML file from a project it should copy the related files folders only , which is embedded to this or linked to this HTML file so we can eliminate the unwanted pictures and folders.


Thanks
Your help will be appreciated

Re: Take only Dependent or related file and folders

Posted: 21 Mar 2013 19:24
by highend
regexmatches() to get all the links from that document. Convert them to relative paths / files and recreate that structure afterwards.

Re: Take only Dependent or related file and folders

Posted: 21 Mar 2013 19:31
by shamsudeen
highend wrote:regexmatches() to get all the links from that document. Convert them to relative paths / files and recreate that structure afterwards.
Thank you for reply brother. But I did not get you, will you please guide me how to do this ?

Thanks

Re: Take only Dependent or related file and folders

Posted: 21 Mar 2013 19:42
by highend
You have to write a script, that uses regexmatches() to capture all the relevant information from a html file and convert these to the current document structure.

An example:

Code: Select all

$test = <<<>>>
<div id="postcard_container">
	<div id="postcard">

		<!-- TOP LEFT CORNER'S MAIL ADDRESS -->
		<div class="email"><a href=""><img src="./images/mail.png" alt="E-Mail an uns" /></a></div>
		
		<!-- BOTTOM RIGHT CORNER'S SOCIAL ICONS -->
		<ul class="icons">
		</ul>
	
		<!-- COUNTDOWN -->
		<div id="countdown"><script type="text/javascript" src="./js/countdown.js"></script></div>		

	</div>
</div>

<!-- MAILING LIST -->
<div class="mailing_list_container">
	<div class="mailing_list">
		<div id="email"><a href="mailto:abc@def.de"><img src="./images/button-mail.gif" alt="E-Mail an uns" /></a></div>
	</div>
</div>
>>>;

	$qm = chr(34);
	$imgLinks = replacelist(regexmatches($test, "<img\ssrc=[""'][^""]*", "|"), "<img src=|$qm", "", "|");
	text $imgLinks;
Have fun.