Final answer:
To write a script that meets the given requirements, you can use a programming language like Python.
Step-by-step explanation:
To write a script that meets the given requirements, you can use a programming language like Python. Here is an example script:
import os
import sys
# Check if the first parameter is a directory
if not os.path.isdir(sys.argv[1]):
print('Error: First parameter is not a directory')
sys.exit()
# Check if there are more than two parameters
if len(sys.argv) > 2:
print('Error: Too many parameters')
sys.exit()
# Loop through all files in the directory
for filename in os.listdir(sys.argv[1]):
if filename == sys.argv[2]:
print('INVALID FILE EXISTS: ' + filename)
elif sys.argv[2] in filename:
print('Error: ' + filename.replace(sys.argv[2], '[REPLACED STRING]'))
else:
print(filename)