Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::fs::read_dir;
- use csv::Writer;
- use chrono::Local;
- mod libs;
- use libs::Audio;
- mod cli;
- use cli::Cli;
- fn main() {
- let cli = Cli::new();
- let src = cli.src.unwrap_or_default();
- let dst = cli.dst.unwrap_or_default();
- let op = cli.op.unwrap();
- let dd = Local::now().format("%d%m%Y-%H%M");
- let file = format!("{}/{}_{}_{}", dst, op, dd ,"audios_duration.csv");
- let mut wtr = Writer::from_path(file).unwrap();
- let _ = wtr.write_record(&["Nome","Duração"]);
- for entry in read_dir(src).expect("source directory not found.") {
- let entry = entry.unwrap();
- if entry.path().is_file() {
- match entry.file_name().to_string_lossy() {
- f if f.ends_with(".wav") | f.ends_with(".mp3") | f.ends_with(".mp4") => {
- let res = Audio::get_length(entry);
- let _ = wtr.write_record(&[res.name, res.duration]);
- },
- _ => continue,
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement