I have a Vector that has set of file paths that gets list of mp3 files.what i need to do is remove the path and get the filename from the each of the vector item so if i have /home/user/Downloads/filename.ext the extracted string should be filename.ext how can i implement in rust?
You can try this (std::path::Path utility in the standard library)
use std::path::Path;
let path = Path::new("my_folder/file.txt");
let filename = path.file_name().unwrap();
println!("{}", filename.to_str().unwrap());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With