bash script problem
I tried creating this script to fix some extensions on some mp3 files i'm getting from the linux dc++ client.
#!/bin/bash
suffix=.mp3
if [ -n "$1" ]
then
directory=$1 #If directory name given as a script argument
else
directory=$PWD #Otherwise current working directory
fi
for file in $directory/*.dctmp
do mv \"$file\" \"${file%.m*p}$suffix\"
done
The script seems to work properly when i'm testing with the echo command just before the mv, but when i remove the echo i get this response - mv: when moving multiple files, last argument must be a directory
I'm imagining it's to do with the spaces in the file names, but i'm not sure. If i leave the echo command in and then copy the output and then paste it in the mv commands work fine.
Here's a sample of the command from the echo based version - mv "/home/mark/.dc++/Incomplete/04 Dormir Au Bord D'une Autoroute.mp3.dctmp" "/home/mark/.dc++/Incomplete/04 Dormir Au Bord D'une Autoroute.mp3"
Running Ubuntu Hoary.
Any ideas?
|