Solve the disorder of A6 avant media player

My wife's Audi A6 avant, from my itunes, from music library COPY to SD card, inserted into the media player, checked that the songs in each album are out of order. After thinking about many ways, it can't be solved. Finally, I thought, is it sorted according to the file creation time?

Then COPY the whole library to the computer, format the SD card, write a certain degree, and write it in Wu order after sorting by name, so that the time and name sorting correspond to each other.

package com.company;

import java.io.File;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.Comparator;

public class Main {

    public static void main(String[] args) throws  Exception{
        File rootdir = new File("/Users/axman/DeskTop/music"); //Library catalog
        String distroot = "/Volumes/Ercui-SD/";                          //SD card
        File[] subdirs = rootdir.listFiles();                            //Singer catalogue
        Arrays.sort(subdirs, new Comparator<File>() {
            @Override
            public int compare(File o1, File o2) {
                return o1.getName().compareTo(o2.getName());
            }
        });
        for (File sub : subdirs) {
            if (sub.isDirectory()) {
                File[] sets = sub.listFiles();                          //Album catalogue
                Arrays.sort(sets, new Comparator<File>() {
                    @Override
                    public int compare(File o1, File o2) {
                        return o1.getName().compareTo(o2.getName());
                    }
                });
                for (File set : sets) {
                    if (set.isDirectory()) {
                        File distdir = new File(distroot + sub.getName() + "/" + set.getName());
                        System.out.println(distdir.getPath());
                        distdir.mkdirs();                               //Create artist directory on SD card
                        File[] musices = set.listFiles();
                        Arrays.sort(musices, new Comparator<File>() {
                            @Override
                            public int compare(File o1, File o2) {
                                return o1.getName().compareTo(o2.getName());
                            }
                        });
                        for (File music : musices) {
                            //Copy file to dist\
                            File distfile = new File(distdir, music.getName());
                            Files.copy(music.toPath(),distfile.toPath());   //File COPY to SD card
                            Thread.sleep(1);                          //Prevent two files from being copied in the same millisecond
                        }
                    }
                }
            }
        }
    }
}

Then plug the SD card back into the car, open it again, ha ha, everything is done.

Tags: Java

Posted on Mon, 02 Dec 2019 04:02:46 -0500 by davidjwest