function cp_mp3_to { PID=`pidof audacious2`; FILEPATH=`lsof -p $PID| grep mp3| sed s/[^\/]*//`; cp "$FILEPATH" "$1"; }

Copies currently played song in Audacious to selected directory

Maybe it could work for any music player if you change "audacious2" with the string you see in `ps aux` for your player. Needs testing in different systems.
Sample Output
$ cp_mp3_to /mnt/flash/car_music/

1
By: ivanatora
2010-12-06 16:31:58

These Might Interest You

  • This is not recommended... lossy -> lossy = lossier. Still, you can do it! ;)


    0
    find . -iname '*.mp3' | while read song; do mpg321 ${song} -w - | oggenc -q 9 -o ${song%.mp3}.ogg -; done
    renich · 2010-03-14 11:34:35 0
  • This command copies all filenames in the current dir and subdirs that end in .mp3 regardless of case (also matches .MP3 .mP3 and .Mp3) It copies all the files to the "mp3" folder in your home directory. If you want to see the files that are beeing copied, replace "cp {}" with "cp -v {}"


    1
    find . -type f -iname '*.mp3' -exec cp {} ~/mp3/ \;
    SlimG · 2009-12-09 00:19:14 2
  • I can remember "cp -av" on Unix like systems to copy files and directories. The same can be done on Windows without extra software, somewhat. The switches mean: /E Copies directories and subdirectories, including empty ones. Same as /S /E. May be used to modify /T. /H Copies hidden and system files also. /Y Suppresses prompting to confirm you want to overwrite an existing destination file. /Z Copies networked files in restartable mode. /I If destination does not exist and copying more than one file, assumes that destination must be a directory. /K Copies attributes. Normal Xcopy will reset read-only attributes. /F Displays full source and destination file names while copying. I don't type that all the time, I stick it into a file called "cpav.cmd" and run that. echo xcopy /e/h/y /z/i /k /f %1 %2 > cpav.cmd cpav zsh zsh2 http://support.microsoft.com/kb/323007 Show Sample Output


    -3
    xcopy /e/h/y /z/i /k /f src dest
    piyo · 2009-02-13 16:25:09 0
  • It copies the entire current working directory to the destination directory with compression enabled.


    1
    gtar cpf - . | (cd /dest/directory; gtar xpf -)
    mnikhil · 2009-05-15 13:23:00 1
  • Just give it an artist and/or song at the end of the command as shown. Show Sample Output


    4
    python2 -c 'import urllib2 as u, sys as s, json as j, subprocess as p;p.call(["mplayer", u.urlopen(j.loads(u.urlopen("http://ex.fm/api/v3/song/search/%s" % "+".join(s.argv[1:])).read())["songs"][0]["url"]).geturl().split("#")[0]])' lenny kravitz fly away
    nagev · 2013-09-21 02:25:51 0
  • If you have lots of subversion working copies in one directory and want to see in which repositories they are stored, this will do the trick. Can be convenient if you need to move to a new subversion server. Show Sample Output


    0
    (for i in `find . -maxdepth 2 -name .svn | sed 's/.svn$//'`; do echo $i; svn info $i; done ) | egrep '^.\/|^URL'
    jespere · 2010-05-09 11:54:37 0

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: