Note that there are some explanatory texts on larger screens.

plurals
  1. POPython: How to loop a process
    primarykey
    data
    text
    <p>I'm working on making a small app/script for putting my mp3's in a folder hierarchy the way I want it, as I haven't found a solution for Unix that is just quite right. So I decided to work on my own. This is an excerpt</p> <pre><code>if musfile[0]: m = musfile[0] tag.link(m) mar = str(tag.getArtist()) mal = str(tag.getAlbum()) mti = str(tag.getTitle()) #m1track = str(tag.getTrack()) os.rename(m,mar + ' - ' + mti + '.mp3') m = mar + ' - ' + mti + '.mp3' os.makedirs(newmusicdir + '/' + mar + '/' + mal + '/') shutil.copy(m,newmusicdir + '/' + mar + '/' + mal + '/') if musfile[1]: m = musfile[1] tag.link(m) mar = str(tag.getArtist()) mal = str(tag.getAlbum()) mti = str(tag.getTitle()) #m1track = str(tag.getTrack()) os.rename(m,mar + ' - ' + mti + '.mp3') m = mar + ' - ' + mti + '.mp3' os.makedirs(newmusicdir + '/' + mar + '/' + mal + '/') shutil.copy(m,newmusicdir + '/' + mar + '/' + mal + '/') </code></pre> <p>And so on. However, in order to organize more than one file, I have been just reusing blocks of code. However, this is extremely inefficient for several blocks of code. For example, if I wanted to organize just 50 songs with my method, I would have over 500 lines of code, for something so simple. So I was wondering if there is anyway I could use loops. However, the problem with using loops is that with each block I must change the number in the list. For example, from block one to two, I must change <code>musfile[0]</code> to <code>musfile[1]</code>, and I do not know how to do that with loops. In fact I have little knowledge about loops. Am I clear enough? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload