Code: Select all
Date - long file name with spaces
Code: Select all
for file in *.*.2017*; do mv "$file" "${file/\ *./}" done
Code: Select all
mv: target ‘done’ is not a directory
Code: Select all
Date - long file name with spaces
Code: Select all
for file in *.*.2017*; do mv "$file" "${file/\ *./}" done
Code: Select all
mv: target ‘done’ is not a directory
In bash, a command ends on a newline or a semi-colon. As there is no newline or semi-colon before done the word done is interpreted as an argument to the mv command. And since your mv command has three or more arguments, the last argument must be a directory, hence the error message.Code: Select all
for file in *.*.2017*; do mv "$file" "${file/\ *./}" done
Code: Select all
for file in *.*.2017*; do mv "$file" "${file/\ *./}" ; done
Code: Select all
for file in *.*.2017*; do
mv "$file" "${file/\ *./}"
done
pjsr2 wrote:In bash, a command ends on a newline or a semi-colon. As there is no newline or semi-colon before done the word done is interpreted as an argument to the mv command. And since your mv command has three or more arguments, the last argument must be a directory, hence the error message.Code: Select all
for file in *.*.2017*; do mv "$file" "${file/\ *./}" done
Use either:orCode: Select all
for file in *.*.2017*; do mv "$file" "${file/\ *./}" ; done
Amongst my favorite links on bash programming are: http://www.tldp.org/LDP/abs/html/ and https://mywiki.wooledge.org/BashPitfallsCode: Select all
for file in *.*.2017*; do mv "$file" "${file/\ *./}" done