remove names based list of name from notepad/csv

Advanced Renamer forum
#1 : 24/08-19 08:04
Tekuno paatii
Tekuno paatii
Posts: 3
Hi. Sorry for my english.
I have many list of name in notepad, then, how to delete a files name with the source from notepad/csv ?
only know rename with Replace List method, are there have other methods ?
I want to delete some of name based in notepad/csv.
everything name written in notepad should be deleted.

list notepad :
andy
betha
chand
defoe
ethan

my file name :
Class A1 [michael andy roland ethan]
Class A2 [randy nina sean defoe]
Class A3 [chand alex maria betha]


24/08-19 08:04 - edited 24/08-19 10:24
#2 : 25/08-19 12:34
David Lee
David Lee
Posts: 1125
The obvious answer would be to use the List replace method. Unfortunately so far there is no way of importing the list from a file so this will not be a workable solution for a large number of names.

A workaround is to use the Script method with the replacements hard-coded. Add spaces before and after the list of students as delimiters and then replace "space+name+space" with "space" for each student. Finally remove the two additional spaces.

For your limited example enter the script:

var str = item.name;
str = str.replace("[","[ ");
str = str.replace("]"," ]");

str = str.replace(" andy "," ");
str = str.replace(" betha "," ");
str = str.replace(" chand "," ");
str = str.replace(" defoe "," ");
str = str.replace(" ethan "," ");

str = str.replace("[ ","[");
str = str.replace(" ]","]");
return str;

Obviously entering all the code manually will be tedious if you have a large number of names to remove. However you can easily create the middle block of code from your existing list automatically, using Excel (or a similar spreadsheet application).

If you are using Excel: import your file containing the list of names into the first column of a worksheet and paste the following formula into cell B1:

="str = str.replace("" "&A1&" "","" "");"

This will create the code: str = str.replace(" name_in_A1 "," ");

Copy the formula down to the end of the worksheet then copy the contents of column B and paste as code into the Renamer script.


25/08-19 12:34
#3 : 27/08-19 04:34
Tekuno paatii
Tekuno paatii
Posts: 3
thank you for your answer
it really saved my time.
actually until now I use almost the same method but a different way.
I write all the names in Excel like this.
\andy[space]
\betha[space]
\chand[space]
\defoe[space]
\ethan[space]

copy all name & paste to the word. find&replace a Paragraph mark + Tab Character then replace all.
and the result is like this
\andy \betha \chand \defoe \ethan

im using remove patern methods to remove all the name.


27/08-19 04:34 - edited 27/08-19 17:04
#4 : 13/10-19 20:20
Lax
Lax
Posts: 6
Reply to #3:
It is a good method but can we load a text file containing the list of names to be removed line by line.

I am currently using below code.

var str = item.name;
str = str.replace("[ASF Systems]","");
str = str.replace("[Block Radar]","");
...
...
..

return str;

The script removes the information in the quotes. But it would be way easier to read this information from a .txt file containing line by line information.

Is there any way to achieve this like in python? I am not familiar with jscript.

file = open("File location", r)
line = file.readline()
while (line):
line = re.sub ('\n$', "", line)
info += line + "|"
line = file.readline()

file.close()




13/10-19 20:20 - edited 14/10-19 00:11