LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-12-2014, 07:15 AM   #1
beopen
LQ Newbie
 
Registered: May 2012
Posts: 21

Rep: Reputation: Disabled
delete a html file along with its associated folder


hi,
i have a huge folder with lots of webpages saved as with the "webpage complete" option.
As of now when i delete a particular saved webpage, i find that the webpage is deleted but its associated folder in which the various images,scripts,etc are stored is left over as a residue. Thus today in that folder, i have residual folders of webpages whose html file has been deleted by me.
As a result the folder is cluttered with lots of those residual folders of html files which are no longer present.
The only option currently which i do is boot into windows where i copy that main folder.Cut-copy-paste the remaining html files to some other folder.
***
Now under windows when you delete a html file saved with the "webpage complete" option, upon deletion both the head and tail gets deleted. Whereas in linux the head goes but the tail remains.
***
This finally leaves me with the orphaned folders of those webpages whose html files i have deleted.
Then i delete those folders/the main folder itself.
Copy back the remaining html files folder back into linux.
Now i want to ask , is there any way to accomplish the same cleanly in linux ?
Currently in linux, i have to first click the html file and then search above for the corresponding folder and then del both.
For one or two webpages it is fine, but when lots of webpages are saved, i am forced to resort to the previous process to avoid tediousness & keep the folder clean.

regards
 
Old 08-12-2014, 07:29 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,876
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
I don't believe so. I have seen the same behavior where you delete the top HTML file under Windows and it gets rid of the associated sub-folder. I don't like that behavior and so when Linux does not behave this way, I'm fine. On the other hand, I've never seen it be more than one folder at the top level; i.e. if you save a web page complete as <blah-blah>.HTML then it will make a sub-folder titled "<blah-blah>_files" and if there were a lengthy hierarchy under that, so be it. My point there is that you delete the HTML file and the one extra step would be that you'd have to delete the associated similarly named sub-directory.
 
Old 08-16-2014, 04:32 AM   #3
beopen
LQ Newbie
 
Registered: May 2012
Posts: 21

Original Poster
Rep: Reputation: Disabled
well , what you have written i have already covered in my post.
i am asking an answer and if there is one i would definitely like to hear.
On my part i know that since everything is a file in linux, when you delete the html file the html file only goes, for the corresponding folder will be treated as another file, even though technically it is associated with that html file and thus it is left as a residue in layman's words. The same is recognized in windows and taken care of and just like "dependency" in package mgt in linux so is "association" in html files, which is nothing but a intelligent aspect there in windows. Maybe this may be missing in linux.
Nevertheless , i put the query so as to get an idea, if there is anything further way to get the same done, and which i am not knowing and missing in my knowledge.

Last edited by beopen; 08-16-2014 at 04:57 AM.
 
Old 08-16-2014, 06:08 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by beopen View Post
(..) the corresponding folder will be treated as another file, even though technically it is associated with that html file
No, that is an interpretation. From a file system point of view the name the file is saved as and the directory holding the related files strictly speaking aren't even the same: both Firefox and Opera will tack "_files" onto the directory name. Cleaning up could look something like this:
Code:
find /some/path/ -maxdepth 1 -type d -iname \*_files | while read ITEM; do [ -f "${ITEM//_files/}.html" ] || echo "rm -rf ${ITEM}"; done

Quote:
Originally Posted by beopen View Post
The same is recognized in windows
Simply put Windows does not equal Linux.
 
Old 08-17-2014, 12:43 PM   #5
beopen
LQ Newbie
 
Registered: May 2012
Posts: 21

Original Poster
Rep: Reputation: Disabled
yeah you are right on that. i just missed that "_files" to the directory. Just saw after your post. All directories are having the "_files" appended to the name. Though on a gross look it seems they must be having the same names.

But that command which you have put is too much for me. I am not that a big advanced user in linux of that depth.
So i guess i go the simpler manual way which i am right now doing by going to windows and deleting such huge folders, for it is getting my work done.
The problem occurs only when i save a lot of webpages and dont attend to them immediately. One or two is not a problem. May be i may have to alter my work method then.
thanks for your replies
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to add a php file in /var/www/html folder mukeshk.nist Linux - Software 2 01-24-2010 11:20 PM
Find folders with ONLY one specific file in and delete file and folder - How ? gedi1 Linux - Newbie 5 10-21-2009 08:09 PM
apache2 folder 'var/www' is not shareable; can not edit the index.html file mcanallyd Linux - Newbie 2 06-18-2009 05:46 PM
Bash script to delete folder's that are listed in a text file Bone11409 Programming 26 01-16-2009 02:55 PM
Help create perl script for delete file/folder sportivo888 Linux - Newbie 5 12-05-2007 11:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration