Reputation: 15
Im trying to rename some files with the format Week_XX_2018-XX-XX_-_2018-XX-XX.md
to Week_XX_2018-XX-XX/2018-XX-XX.md
. So changing _-_
to /
.
I tried to use rename
and first tested it with the -n
option. This works fine and shows something like this for all the files:
$ rename -n 's/_-_/\//g' *
rename(Week_01_2018-12-03_-_2018-12-09.md, Week_01_2018-12-03/2018-12-09.md)
...
However, when executed without the -n
option the command fails. It says
Can't rename Week_01_2018-12-03_-_2018-12-19.md Week_01_2018-12-03/2018-12-09: No such file or directory
Why does this happen? How can the test of the command work but not the actual command?
Upvotes: 0
Views: 93
Reputation: 52317
The character '/' is special as it is used as path delimiter. See Is it possible to use "/" in a filename? for a more detailed answer on why your rename fails.
Upvotes: 1