In my directory, there are some html files contains such a string:
sceneFilePath: "./video/video/960.mp4",
What I need to do is to replace the path above with the right path. So I write a script to do that:
find ./video -type f -name "*.mp4" -print0 | while IFS= read -r -d '' myfile; do
tmp=$(basename "$myfile") #example.mp4
tmp="${tmp/.mp4/.html}"
# Here I create a file named $tmp according to a template with the command `cp`
cp -rf index.html "$tmp"
sed -i '' "s#sceneFilePath:.*,#sceneFilePath: \"${myfile}\",#g" "$tmp"
done
But it doesn't work.
Here is an example of $myfile
:
./video/Bentota & Hikkaduwa/Hotels/River House/River House - Balapitiya.mp4
It seems that it is because of the $myfile
, which contains some special characters, such as ,
&
, -
, or that it is because the .*
can't match ./video/video/960.mp4
.