LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > *BSD
User Name
Password
*BSD This forum is for the discussion of all BSD variants.
FreeBSD, OpenBSD, NetBSD, etc.

Notices


Reply
  Search this Thread
Old 05-26-2011, 12:45 PM   #1
ManyouRisms
LQ Newbie
 
Registered: May 2011
Posts: 3

Rep: Reputation: Disabled
Running a python script on multiple files


Hey guys. I'm trying to run a python script that was created to reencode mp3 files. When I run the script on one mp3I have no problem but I can't figure out why it's not outputting multiple files. Terminal acts like ts doing something but no files are being created in the folder I specify.
I'm running:

Code:
nice -20 python decrypter.py /var/mobile/Library/Downloads/Music/*.mp3 

/var/mobile/Library/Downloads/Music/Music $i $RANDOM.mp3
because I have about 200 mp3s in the folder, and the random is because the mp3s currently are named in numbers and I'll have to figure out the rest later, for now I just want them encoded.

Any ideas what is wrong with what I'm putting?

Last edited by ManyouRisms; 05-26-2011 at 12:47 PM. Reason: Code didn't post properly
 
Old 05-26-2011, 10:13 PM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Try running it in a loop

Code:
for file in /var/mobile/Library/Downloads/Music/*.mp3
do
    python decrypter.py ... $file
done
You'll need to fix up the command obviously ...
 
Old 05-27-2011, 07:27 AM   #3
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Is there something unique about the Python that is installed on the BSDs? Otherwise this should be in Programming.
 
Old 05-27-2011, 11:24 AM   #4
ManyouRisms
LQ Newbie
 
Registered: May 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
@archtoad6. Nothing particularly special about the script but afaik the problem isn't with the script it's how I'm running it via command line,which is why I put it here. I understand if yo want to move it though, my apologies.

@kbp thanks a lot I'll give it a go now and post back.

Edit: Okay I've done


cd /var/mobile/Library/Downloads/Music/
for files in [ "${1##*.}" = "mp3" ]
do
** *nice -20 python /var/mobile/decrypter.py /var/mobile/Library/Downloads/Music/*.mp3 $file
done

What it does is take one file and reencode it but in place instead of a encoded copy. Not sure where else to go with this.

Last edited by ManyouRisms; 05-27-2011 at 05:59 PM. Reason: Updates
 
Old 05-27-2011, 10:14 PM   #5
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Your command is still wrong, I don't think you should be referencing multiple files (.../*.mp3)
 
Old 05-29-2011, 10:11 PM   #6
rocket357
Member
 
Registered: Mar 2007
Location: 127.0.0.1
Distribution: OpenBSD-CURRENT
Posts: 485
Blog Entries: 187

Rep: Reputation: 74
Quote:
Originally Posted by kbp View Post
Your command is still wrong, I don't think you should be referencing multiple files (.../*.mp3)
That's absolutely correct. Is the op using the Grooveshark decrypter as referenced here?

If so, you're using the utility wrong. You're giving it a list of files instead of <infile> and <outfile>.

A correct version (in theory...I didn't test it haha):

Code:
cd /var/mobile/Library/Downloads/Music/
[ -d ../decrypted/ ] || mkdir ../decrypted/
for file in [ "${1##*.}" = "mp3" ]
do
    nice -20 python /var/mobile/decrypter.py $file ../decrypted/$file
done
That will decrypt each file and place the decrypted file in /var/mobile/Library/Downloads/decrypted/

Last edited by rocket357; 05-29-2011 at 10:12 PM.
 
Old 05-30-2011, 10:57 AM   #7
ManyouRisms
LQ Newbie
 
Registered: May 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
far out, this seems to be working a treat. i forgot by using ´for file in´ i was defining $file so i didnt need the *.mp3. thanks a lot guys, i´m just starting to have a bit of fun with this so hopefully i can make it through the rest of my ebooks.

cheers

jesse
 
Old 06-01-2011, 04:49 AM   #8
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
If that means it's solved, please mark it so.
 
  


Reply

Tags
[python]



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[Help] Running an interactive (python) script in tty1 before login Thomaz Linux - Software 1 04-22-2011 05:38 PM
Creating a script to move or copy files into multiple directories below the files matthes138 Linux - Newbie 5 08-25-2009 04:57 PM
Error while running a python-ogre script konqi Programming 4 01-03-2008 12:43 PM
Running script (probably python) Bob Jones Linux - Software 1 09-29-2007 01:20 AM
Running Python Script in UBUNTU Session Manager warnetgm Linux - Newbie 2 12-06-2006 03:08 PM

LinuxQuestions.org > Forums > Other *NIX Forums > *BSD

All times are GMT -5. The time now is 04:58 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
Open Source Consulting | Domain Registration