shanenin Posted July 24, 2005 Report Share Posted July 24, 2005 I am writing a script to rename avi files. The current files have spaces in themfrom the current directory I have these two titles. for example"sopranos-301 the car episode""sopranos-302 the murder episode"I am running the script from the directory the files are infor i in *; do echo "enter the new name you would like to change the file to" read INPUT # i have the mv command in quotes because the file has spaces in the name mv \"$i\" ${INPUT}doneit is giving me an arror about mv can't move multiple files to a non directory. As far as I can see \"$i\"is only specifing one file Quote Link to post Share on other sites
jcl Posted July 24, 2005 Report Share Posted July 24, 2005 Escaping the quotes is disabling their quoting behavior; you end up prepending a quote to the first word of the file name and append a quote to the last. Replace the escaped quotes with unescaped double quotes and it'll work. Quote Link to post Share on other sites
shanenin Posted July 24, 2005 Author Report Share Posted July 24, 2005 (edited) Thanks, that worked. doing dumb stuff like that, I wonder how I ever manage to get anything to work. If you care to save a few keystrokes when remnaming stuff feel free to use this script #!/bin/sh# for this script to work you must be in the directory that contains the files you # want to renameclearecho "Does the directory listed contain the files you would like to rename?"echoecho "`pwd`"echoecho "enter return to continue, or type 'quit'(and return) to exit the script and change to the correct directory"read Fif [ $F = "quit" ] then exitficlearfor i in *; do clear echo "do you want to change the name of the file" echo echo $i ? echo echo "enter 'y' to rename it, or 's' to skip this file, or 'q' to exit this program" read INPUT while [ ${INPUT} != y ] && [ ${INPUT} != s ] && [ ${INPUT} != q ]; do echo "please choose from choices y, s, or q" read INPUT done case ${INPUT} in y) echo "enter the new name you would like to change the file to" read FILE_NAME mv "$i" ${FILE_NAME} if [ "$?" = 0 ]; then echo "the file named $i was changed to ${FILE_NAME}" echo "press return to continue" read pause else echo "an error occurred when moving the file, exiting the script" exit 1 fi;; s) echo "the file $i was not renamed";; q) exit;; esacdone Edited July 24, 2005 by shanenin Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.