How to run the script in terminal linux

Your directory paths begin with "/" which indicates they're paths starting at the filesystem root. Did you want to use relative paths to the directories? If so, drop the leading slash.

For diagnosing problems with finding files, see if the script works using the full absolute path to the file first. If the full path to the file works. If that works, it indicates that the issue is with relative paths. Usually, because there's an assumption that the working directory of process isn't where you think it is.

A sanity check here might be to throw in

# Print the working directory
getwd()

# Check if the working directory exists
dir.exists(getwd())

# List files in the working directory
list.files(getwd())
2 Likes