# this is the code import os import subprocess import ipdb root_dir = '/home/pratz/Desktop/music/' target_dir = '/home/pratz/Desktop/test_music/' for root, subfolder, files in os.walk(root_dir) : ipdb.set_trace() for fl in files : if ".mp3" in fl : target = target_dir + fl.replace(' ','_') compress_ffmpeg = ["ffmpeg","-i",fl,"-ab","128k", target] subprocess.call(compress_ffmpeg,shell=True) # And this is the dir structure ( ipython ) In [6]: test_walk = os.walk("/home/pratz/Desktop/music/") In [7]: [ (x,y,z) for x,y,z in test_walk] Out[7]: [('/home/pratz/Desktop/music/', ['akon'], []), ('/home/pratz/Desktop/music/akon', ['Freedom [2008]'], []), ('/home/pratz/Desktop/music/akon/Freedom [2008]', [], ['14-Akon-Clap Again (BONUS).mp3', '12-Akon-Over The Edge.mp3', "05-Akon-We Don't Care.mp3", '01-Akon-Right Now (Na Na Na).mp3', '03-Akon-Keep You Much Longer.mp3', '04-Akon-Troublemaker Ft. Sweet Rush.mp3', '08-Akon-Against The Grain Ft. Ray Lavender.mp3', '11-Akon-Birthmark.mp3', '10-Akon-Sunny Day Ft. Wyclef.mp3', '13-Akon-Freedom.mp3', '07-Akon-Holla Holla Ft. T-Pain.mp3', "06-Akon-I'm So Paid Ft. Lil' Wayne And Young Jeezy.mp3", '09-Akon-Be With You.mp3', '00-Akon-Freedom-2008-[NoFS]-COVER.jpg', "02-Akon-Beautiful Ft. Colby O'Donis And Kardinal Offishall.mp3"])] # when i run the program i am getting the error FFmpeg version SVN-r0.5.1-4:0.5.1-1ubuntu1.3, Copyright (c) 2000-2009 Fabrice Bellard, et al. configuration: --extra-version=4:0.5.1-1ubuntu1.3 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --disable-stripping --disable-vhook --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --enable-shared --disable-static libavutil 49.15. 0 / 49.15. 0 libavcodec 52.20. 1 / 52.20. 1 libavformat 52.31. 0 / 52.31. 0 libavdevice 52. 1. 0 / 52. 1. 0 libavfilter 0. 4. 0 / 0. 4. 0 libswscale 0. 7. 1 / 0. 7. 1 libpostproc 51. 2. 0 / 51. 2. 0 built on Dec 21 2011 18:37:21, gcc: 4.4.3 At least one output file must be specified