LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   delete a html file along with its associated folder (https://www.linuxquestions.org/questions/linux-general-1/delete-a-html-file-along-with-its-associated-folder-4175514431/)

beopen 08-12-2014 07:15 AM

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

rtmistler 08-12-2014 07:29 AM

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.

beopen 08-16-2014 04:32 AM

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.

unSpawn 08-16-2014 06:08 AM

Quote:

Originally Posted by beopen (Post 5221940)
(..) 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 (Post 5221940)
The same is recognized in windows

Simply put Windows does not equal Linux.

beopen 08-17-2014 12:43 PM

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


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