zoukankan      html  css  js  c++  java
  • Nintendo Switch相册整理

    NS的相册是按日期命名的,因此会产生很多文件夹,不太好找对应的照片或视频,而且文件名是md5码。

    平时整理照片老费劲,所以我用Qt写了段整理NS照片和视频的代码:

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QFileDialog>
    #include <QAction>
    
    #define FILE_VIDEO "Video"
    #define FILE_PHOTO "Picture"
    
    MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
        , ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    
        mapGameCodeToName = {
            {"0C015090E6C5E3F06D97FEDE95458758","路易鬼屋3"},
            {"0DC6ECE91CF3F6F02BAFC002E3FFBAAD","火焰纹章风花雪月"},
            {"2AE606B8659FEA852E0ED6470C9814D9","怪物猎人GU"},
            {"3C66B776DB1AA06323037049FACD96D3","精灵宝可梦剑"},
            {"3D69A7ED02A1FF371048829E22A49194","暗黑破坏神3"},
            {"6E673B692CCAB4448DD9F18F4ECB7015","莱莎的炼金工坊"},
            {"57B4628D2267231D57E0FC1078C0596D","switch主机页面"},
            {"93C1C73A3BAF9123A15B9B24886B634B","歧路旅人"},
            {"257FD939428E4BFE6BF9E2F559D5037A","异界锁链"},
            {"1850B5D674B98147F1AD7C6693369685","生化危机启示录2"},
            {"16851BE00BC6068871FE49D98876D6C5","马里奥赛车8"},
            {"9129043EF2AAD7F1157CF852BACB8F7D","塞尔达梦见岛"},
            {"B8FAEF4816CAC2B76D11869B05CA7601","精灵宝可梦盾"},
            {"B562FBF831DED9A995A48324FB946776","生化危机启示录1"},
            {"D3C2627FB3B01DB86CAE617C61BA4BCD","地狱之刃"},
            {"EADB78E442C41D91A4E58DE37C69F333","妖怪手表4"},
            {"EAF7CD52A6108603A960A810DB55F2D1","巫师3"},
            {"ECCAE210FD0AA1E799B6F807E179FB9A","异度之刃2"},
            {"1C2A3E293842562AF12D9CDE40615E70","战场女武神"},
            {"1CFA4F0AFF14019A30AD91A509EF4A14","乐高世界"},
            {"4A0905EBC935600C869393E1102796BF","乐高DC超级坏蛋"},
            {"9BF728FB47714897C7A6F67DC609B6D4","噬神者3"},
            {"32DCC16A9522010C678790FFCA00ACC5","马里奥疯兔王国之战"},
            {"72CA1DED7AF149F87216AAA92ACC6ECE","NBA2K"},
            {"251B606CAAE97CD7BB1849E9DAD12C82","雷曼传奇"},
            {"5777DA0A4A4401C64F08970B59E4D6F6","哆啦A梦牧场物语"},
            {"9768DE0BB7F81754F000E3332E653D8B","龙之信条"},
            {"39044917CFF4239A6A8855A4FBFD24A3","猎天使魔女1"},
            {"C2B49A475DF5A340494292A1BD398579","星露谷物语"},
            {"D10D2AC2AEDE4E2D25CAE46B7E6326A0","Darksiders Warmastered Edition"},
            {"E27E5ADA5A86332E7C52B3562FCF5A27","猎天使魔女2"},
            {"EEF8E9558A0946A299305EE281E121B4","Mavel Ulitimate Alliance 3: The Black Order"},
            {"FF3DC0CC50E33DEA65489FBE36679C77","战场女武神4"},
            {"F3AD23231727C66A0A2E8CCB30040335","生化危机 未知"},
            {"2262FEF42D66F7291F98BF381C2CF619","歧路旅人试玩版"},
            {"6596C20F0074B600C19784F40D93ECEF","Paladins"},
            {"1E1800B8D04F999C436DDFE2B8CD0B81","黑暗之魂1"},
            {"2FF2ECD3DBCD8F1B42E9361E6B9E85AB","怪物猎人xx"},
            {"3B8C834E3D68EB57C34D0DA0B88E4B3B","星际战甲"},
            {"5E92066D83C981FCBC05AE4D9711906A","FC游戏"},
            {"7D6F548625BC0EB94C235FFE679A3299","分手厨房2"},
            {"8AEDFF741E2D23FBED39474178692DAF","马里奥奥德赛"},
            {"11B64E28AD7A49CA9EC8AC007BE858C6","我的世界基岩版"},
            {"22A4BDEA5363AAA24F931D5AF2926082","空洞骑士"},
            {"74EA5D8C57EB2F39A242F585A490F51B","上古卷轴5"},
            {"94CAAF6C83EE682D358EB6183EEF7D28","去吧皮卡丘"},
            {"132FFFF5F327DE6F279A68813E35AD5D","塞尔达无双"},
            {"5175A9E8354E328724729A6641D0F22F","ARMS"},
            {"7589FF7625E38498B948C61898499F87","刺客信条3"},
            {"A67942211CD1A968913B304D86B5486A","王者荣耀"},
            {"E1A7E95F9E577242170CB3869DA3D3AF","未命名"},
            {"E106A613E0C1B6AC88570F1871104D66","生化危机4"},
            {"EFC27116AB7654BE16347FB0B3BC7375","沙滩排球3"},
            {"F1C11A22FAEE3B82F21B330E1B786A39","塞尔达传说荒野之息"},
            {"F489C99A244DF57DCBDC4BFD2DB926F1","堡垒之夜"},
            //{"",""},
            //{"",""},
        };
    
        connect(ui->btnPath, SIGNAL(clicked()), this,SLOT(slotBtnPath()));
        connect(ui->btnDesPath, SIGNAL(clicked()), this,SLOT(slotBtnDesPath()));
        connect(ui->btnAccept, SIGNAL(clicked()),this, SLOT(slotBtnAccept()));
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    QFileInfoList MainWindow::getFileList(QString strPath)
    {
        QDir dir(strPath);
        QFileInfoList file_list = dir.entryInfoList(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
        QFileInfoList folder_list = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
    
        for(int i = 0; i != folder_list.size(); i++)
        {
            QString name = folder_list.at(i).absoluteFilePath();
            QFileInfoList child_file_list = getFileList(name);
            file_list.append(child_file_list);
        }
    
        return file_list;
    }
    
    QString MainWindow::getGameName(QString strCode)
    {
        if(mapGameCodeToName.contains(strCode))
          return mapGameCodeToName[strCode];
        else
          return strCode;
    }
    
    void MainWindow::slotBtnPath()
    {
        QString fileName = QFileDialog::getExistingDirectory();
        ui->lineEditPath->setText(fileName);
    }
    
    void MainWindow::slotBtnDesPath()
    {
        QString fileName = QFileDialog::getExistingDirectory();
        ui->lineEditDesPath->setText(fileName);
    }
    
    void MainWindow::slotBtnAccept()
    {
        QString fileName = ui->lineEditPath->text();
    
        /* 获取文件信息列表 */
        QFileInfoList fileInfoListTemp = getFileList(fileName);
    
        /* 将文件移动至整理好的文件夹 */
         for(QFileInfo fileInfoTemp: fileInfoListTemp)
        {
            QDir dir(fileInfoTemp.filePath());
            QString strName = fileInfoTemp.fileName();
            QStringList strlistNames = strName.split("-");
    
            /* TODO:这里代码写的比较死 */
            if(strlistNames.size() != 2)
                continue;
            if(strlistNames[1].isEmpty())
                continue;
            QString strGameName = getGameName(strlistNames[1].remove("." + fileInfoTemp.suffix()));
            if(strlistCodeAll.contains(strGameName))
            {
                QString strCodePath = ui->lineEditDesPath->text()
                        + "/" + strGameName;
                QString strDesPath = strCodePath
                        + "/" + fileInfoTemp.suffix();
    
                if(!dir.exists(strCodePath))
                    dir.mkpath(strCodePath);
                if(!dir.exists(strDesPath))
                    dir.mkpath(strDesPath);
    
                QFile::rename(fileInfoTemp.filePath(),
                        strDesPath + "/" + fileInfoTemp.fileName());
            }
            else
            {
                strlistCodeAll.append(strGameName);
            }
        }
        /* 输出到listView */
        ui->listWidgetCode->addItems(strlistCodeAll);
    }

    也就花了十来分钟,其实完全可以用C写,嗯,以后有需求再改进。现在遇到的问题是,md5码我是自己整理的。

    Hunter药药
  • 相关阅读:
    c#中使用多线程访问winform中控件的若干问题(转)
    Winform 分页控件(转)
    C#争论:什么时候应该使用var?
    C#的Contains() 值还是引用
    DataTemplate
    DX11_基于GPU_ComputeShader的3D精确拾取
    串行的BitonicSort双调排序
    Directx11_使用Effect框架包装ComputeShader
    Silverlight自适应布局
    poj3626广搜
  • 原文地址:https://www.cnblogs.com/fengyaoyao/p/12238025.html
Copyright © 2011-2022 走看看