How do I use just the filename to rename files use this script syntax?
#!/bin/bash WATCHED=/mnt/Watched DESTINATION=/mnt/Destination inotifywait -re CLOSE_WRITE,CREATE,MOVED_TO --format $'%e\t%w%f' -m $WATCHED | while IFS=$'\t' read -r events new do cp -r "$WATCHED/$new" "$DESTINATION/" done
When I run this I get this result
cp: cannot stat '/mnt/Watched//mnt/Watched/newfile.mkv': No such file or directory
I know that if the format was setup like this
--format %f it would work fine but I cannot set it up that way as I need the events and full path for other parts of my script that I left out. So how do I pull out and assign just the filename for my cp command?