How to remove a text from multiple HTML files in one go? - html

We have implemented around 180 different HTML files. There's one thing common in each file i.e. an email address. But today we came to know that we need to remove that email address from each file. Is there any efficient way that we can remove that email address from all those files once in a go? I really do not want to open up each file one by one and remove that email address from all the files in 180 attempts, really inefficient.

You can use NotePad++ to 'Find in files', this will scan search criteria (and replace the search string, if specified) in a pointed directory. You can easily overwrite the email address by an empty string.

You can achieve this, by using the Windows Power Shell.
Navigate to the root directory of your HTML Files,
and place the following command:
foreach($youroldhtml in (dir -r -i *.html -force)) { $yournewhtml = gc $youroldhtml| where { $_ -notlike "*your email adress goes here*" }; sc $youroldhtml $yournewhtml}
EDIT:
Of course you have to replace your email adress goes here with the email you want to remove.

Related

HTML: how to use a href to link to a file name that starts with # character

I have many text files, the name of which starts with # (hash) sign. It would be very cumbersome to rename the files.
If I try to link to the text files in an HTML file, using <a href="#example.txt"> the browser interprets the leading # character as a "fragment identifier".
My requirement is for the link to open the text file in the browser.
I have tried substituting the leading # character like this:
<a href="#35;example.txt">
<a href="#&23;example.txt">
but that does not work (the text file is not opened).
Is there an HTML work-around, or is JavaScript required for this?
If you really need to do it you can try with replacing "#" with %23. It should work.
You will avoid lots and lots and lots of pain if you are able to rename your files so they don't contain a "#" character.
As long as they do, you will probably have current and future cross-browser issues, confusion on behalf of future developers working on your code (or confusion on your behalf in the future, when you've forgotten the ins and outs of the encoding), etc.
Also, some Unix/Linux systems don't allow "#" in filenames. Not sure what OS you're using, but your filenames should be as portable as possible across OSs, even if you're "sure" right now that you'll never be running on one of those systems.
Problem -
href with a # in front of the file name fails to load the file. This is because you need to URL Encode the symbol.
Solution -
Use %23 which is the URL Encoding for #.
Example -
If you want to use an href to link a file named #test.html, you would do this -
Click Me!
Recommendation -
Do not use file names with # in the name.
If you want to rename all of the files in the directory you are working in, here is a bash script that will do that for you.
#!/bin/bash
target="/home/user/directory/change/$1"
for f in "$target"/*
do
letter=$(basename $f | cut -c1-1)
if [ "$letter" == "#" ]; then
withoutHash=$(basename $f | cut -c 2-)
mv $f $withoutHash
fi
done
This bash script should be easy to understand but there is surely some one liner on Stack Overflow. Try setting up a test directory and playing with it. You could pretty easily figure out how to traverse sub directories if needed.
You have to remove the # in your fileNames. # means an id and the browser thinks its an id and looks for it on the page.

How can I duplicate a folder and change the name?

I'm trying to setup a signup form on my webpage, once the user creates there account, I would like to automatically create a folder of what the user typed in a input with the ID of cfinput, the problem i'm running into, is I am not experienced in the jQuery zones, I focus on creating front-end design using CSS and HTML languages. Summarization, I can't figure out how to create a copy of a folder named base_org and change it's name to what the user wrote in the input listed above,
Any help is greatly appreciated, if you have any questions just comment and I will try to re-edit my post to make it more clear.
JavaScript cannot do this on the client side. You need a backend which processes the signup form submission and creates a copy of your base directory.
A general solution is to call the system's copy command. On Linux, you can copy a directory like this:
cp -r /path/to/base_org /path/to/new_folder
You can execute the shell command in your preferred backend language. For example in PHP, you can use shell_exec:
// process the form first and put username in $username
shell_exec("cp -r /path/to/base_org /path/to/$username");
Make sure the username won't contain any invalid or special characters or other shell commands.
Another option would be to use the backend language's API to copy the directory.

Syntax for # literal in ms-access hyperlink?

This seems like it ought to be a trivial question, but I'm having a hell of a time finding an answer for this so far...
I have an access database that stores hyperlinks to files on a shared network drive. The link targets are specified as simple file paths (e.g. "G:\directoryname\filename.ext") rather than proper URL's ("http://domain.ext/link").
This works fine in general, but I've recently run into a problem involving file names that contain the "#" character. (It is not an option to change the file names to remove the # characters)
If I try to set up a link to something like "G:\directoryname\ExampleFile#24.pdf", then Access parses the # in the filename as it would generally do when it defines a hyperlink. The resulting target is just ""G:\directoryname\ExampleFile", with the portion of the link following the offending "#" simply being truncated.
Now, obviously if the link target were a regular URL, I would just replace the "#" in the text of the link with "%23" and there would be no issue.
The problem is that, if I do that here, my network file action fails, because unlike when opening a regular URL through a browser, the network doesn't recognize %23 as equivalent to # ( I get an error saying "Unable to open G:\directoryname\ExampleFile %23 24.pdf. Cannot open the specified file.")
Is there a more direct way to have ms-access record the link target with a literal # character included?
Well this certainly doesn't help you but here is your answer:
"You cannot use a pound character in a file name for a hyperlink in an Office program"
https://support.microsoft.com/en-us/kb/202261

X++ - Creating a CommaIO object

I have a simple question. When I create a CommaIO, it works but when I arrive to the 'if' statement, it doesn't go to inside the 'if'. The message 'blabla' is never printed. Nevertheless, the file name is correct and the path also. My csv files was saved in Excel with csv(comma delimited) extension. The file and directory are authorized in read mode
commaIO = new CommaIO(#"C:\\Users\\lbagno\\Documents\\SalesPrice.csv","r");
print "blabla";
pause;
print "fdf";
pause;
if(commaIO)
{
print "ici3";
pause;
}
Where is the problem ?
Thank you
When I first saw this I thought it was because you had \\ aswell as the # but seemingly in my code it works when I put it in a job.
Few questions.
try removing the \\ so it is just \ and see whether that fixes it (as I said it doesnt make a difference on mine)
Does the user running AX have access to that file path?
Does the file exist.
A few pointers for you, try using info("string") instead of print and pause, it's more standard and you dont have to pause every step.
Also commaIO has been superceeded by CommaTextIo. Looks like you can use the same code but I'm guessing it adds some functionality. http://msdn.microsoft.com/en-us/library/aa624902(v=ax.50).aspx
I can't comment on this post because of I don't have a high enough reputation so sorry if this isn't helpful as an answer.
Try moving the file to C:\Temp directory. It may be a permissions issue!!
The # makes it a string literal...so you're doing double \\ for no reason...but I think it still does work.
Use one of the two though:
CommaIo commaIO = new CommaIO(#"C:\Users\lbagno\Documents\SalesPrice.csv","r");
CommaIo commaIO = new CommaIO("C:\\Users\\lbagno\\Documents\\SalesPrice.csv","r");
Also, checking if (commaIo) will work if it finds a valid file, then you run while (commaIo.status() == IO_Status::Ok).
I'd say the issue is that either your file does not exist (as typed), it's a client/server issue, OR it's a permissions issue.
Start with a job and a local file.

Bash diff body text of html file only

I'm writing a shell script which tracks the changes of a website and emails me with the contents of the change if one occurs. The idea is to use wget to grab a copy of the html and compare it to the version from the last time the script ran. Wget works fine to save the html file but I'm having trouble comparing the files. The trouble is that I'm only interested in changes in the html file's plain text, not the code, links, etc.
Diff works to find all the changes in the two files but it ALWAYS returns changes even when the plain text is identical. This is because each link on the site has a corresponding authenticity token that differs each time the page is accessed. In order to diff only the lines that include plain text I'm attempting to filter it to exclude any line that begins with "<" OR "(any_amount_of_spaces)<". I've looked at the diff man page but I can't seem to find an operator that will do what I need. I don't know much about REGEX but would that work with diff -I for this?
Thanks!
You could use lynx -dump to render the pages and feed those to diff, but since you are not interested in links you would need to get rid of the References section that this yields (with e.g. awk) rendering this a not-so-robust solution (but maybe good enough for your use case).
If you don't mind using something 3rd-party go for html2text:
diff <(html2text before.html) <(html2text after.html)
PS: There are two different programs called html2text.