Take only Dependent or related file and folders

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
shamsudeen
Posts: 67
Joined: 05 May 2012 06:58

Take only Dependent or related file and folders

Post 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

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Take only Dependent or related file and folders

Post by highend »

regexmatches() to get all the links from that document. Convert them to relative paths / files and recreate that structure afterwards.
One of my scripts helped you out? Please donate via Paypal

shamsudeen
Posts: 67
Joined: 05 May 2012 06:58

Re: Take only Dependent or related file and folders

Post 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

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Take only Dependent or related file and folders

Post 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.
One of my scripts helped you out? Please donate via Paypal

Post Reply