![]() |
Help in deleting no right mouse click code from 10k of pages on server
I've got over 10k in pages, 7 gigs total with images, that has no right mouse click code that I need to delete.
I have a few server scripts that will do search and replace on a server but they only work with one line of code at a time and if there is spaces in the file names and directories which seems to break the script and any of the pages and directories have spaces in the names. :( I do already have a tar file downloaded so I may just have to do this locally and then re-upload everything but damn it is 7 gigs. This is the code, |
If you have the tar, you should only have to upload the changed HTML? yes?
I don't have a solution, but Ray - Webmastersguide/Strongbox, probably will... he should see this thread. DD |
Cleo,
UltraEdit has a very robust Global Search and Replace function built into it that will walk thru multiple files and directories that will do this for you easily. You can download a trial version of it at ultraedit.com and if you end up liking the product (I love it and have been using it for almost 10yrs) registration is only about $40. |
Looks like ultraedit.com is about the same thing as bbedit.com which I use all the time, but just like bbedit doesn't do batch find and replace on the server.
Actually I looked through more files and the code is slightly different in the way it is written in almost every page. |banghead| I'm having a hell of a time getting the tarball to download from the server without it getting corrupt. Best can I do is 2.6 megs transfer speed with my cable modem so it takes something like 18 hours and then ends up being corrupt in the end. I see that the server has rsync installed and my Mac also has rsync so I may end up mirroring the server's drive locally using rsync and just working on everything local. This way once it will still take a few days to get everything downloaded to my local drive but then only the changed files will get re-uploaded. |
|
Wouldn't it be easier to correct one of your scripts so that they handle filenames and directories containing spaces and run your script in your shell? Although, constructing the actual search and replace regexp is going to be a challenge if the script you want to strip is slightly different in each pages as you mentionned. |dizzy| (Unless you want to remove all javascript, then it's nothing)
Also, I'm wondering why you're downloading the whole 7 gigs (including pictures) when you could download a tar containing only html files... Entreri. |
good point Entreri!
use the --exclude [pattern] parameter to exclude all the .jpg files in the tarball and you'll reduce the size quite a bit (assuming that there's a bit of content in your directories. |
Maybe I'm missing something but if I did a tar file and excluded the jpg, gif, wmv, etc. wouldn't I have a problem just replacing these files when I re-uploaded the html in keeping the directory structure as everything is in scatted nested directories all over the place?
|
Quote:
DD |
To remove the code from the pages I don't have to move them. Can you un-tar something and have it replace only the html files while keeping the directories and files untouched?
But I'm thinking now it would probably be a good idea to also remove all the spaces from the directories, html files, and jpgs if I did decide to download this mess. The more I think about it I'm thinking it would probably be best to download one directory at a time and fix them slowly. I have very good find and replace tools on my Mac including a nice editor with Grep and GoLive as some very good site site maintenance tools for getting rid of all the spaces and fixing broken links. |
Quote:
DD |
Quote:
|
http://www.sponsororganizer.com/FreeScripts/cleo.html
Save the script as cleo.pl Chmod it to 755 Run: find /main/domain/dir \( -name '*.html' -o -name '*.php' -o -name '*.htm' \) -exec cleo.pl {} \; It will run through all your .html, .php and .htm files and delete the code. Remember that it will open and save all files, even the ones that doesn't have the code in it (it will just not change anything). So if you have any files that are owned by the webserver user, it _might_ change the owner to the user you run the script as. I made a test run here on a bunch of files with and without the code in, and it worked like a charm. A hot advice is to make a test run in a temp folder :) My ICQ is 252081 if you need any help. Good luck if you decide to use it :) swed |
This looks interesting.
Could I do find /home/foxy/web/members \( -name '*.html' -o -name '*.php' -o -name '*.htm' \) -exec ../../myscripts/remove-right-mouse-code.pl {} \; and this way it would only do the member's directory? |
Quote:
If you only want to do the /home/foxy/web/members dir and no sub-dirs... do this: find /home/foxy/web/members \( -name '*.html' -o -name '*.php' -o -name '*.htm' \) -maxdepth 1 -exec ../../myscripts/remove-right-mouse-code.pl {} \; |
Something is wrong. I'm getting this. ../../myscripts/remove-right-mouse-code.pl: line 5: syntax error near unexpected token `s/(/<' ../../myscripts/remove-right-mouse-code.pl: line 5: `s/(/ |