LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 08-24-2005, 02:48 AM   #1
fatbastard spice
LQ Newbie
 
Registered: Aug 2005
Distribution: Ubuntu
Posts: 2

Rep: Reputation: 0
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?
 
Old 08-24-2005, 03:06 AM   #2
dub.wav
Member
 
Registered: Aug 2003
Location: Norway
Distribution: FC4
Posts: 83

Rep: Reputation: 20
Try to remove the \s from the mv command, you're not supposed to escape the quote marks.
 
Old 08-24-2005, 03:15 AM   #3
fatbastard spice
LQ Newbie
 
Registered: Aug 2005
Distribution: Ubuntu
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks, worked a treat!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script problem GATTACA Programming 3 06-13-2005 10:59 AM
Problem with this bash script cantabile Programming 3 06-06-2005 06:31 PM
bash script problem cookie_ie Programming 3 03-23-2005 03:19 PM
bash script problem sorry99 Programming 2 09-20-2004 10:02 AM
Bash script problem kalleanka Programming 2 01-30-2004 12:59 PM


All times are GMT -5. The time now is 05:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration