"mv: cannot stat file" in for loop
- by F.C.
I wanted to rename a lot of files with a pattern so I tried this for loop:
$ for f in *; do mv \""$f"\" \""HouseMD-S06E${f#*Episode }"\"; done
But I got this error:
mv: cannot stat `"House MD Season 6 Episode 01 - Broken (Parts 1 & 2).avi"': No such file or directory
So what I did was echo the mv commands to a file like this:
$ for f in *; do echo mv \""$f"\" \""HouseMD-S06E${f#*Episode }"\">>mv.txt; done
And the run the file with source.
Any ideas why the first for didn't work and how can I fix it?