Delete files from directory if filename contains a certain word

To expand on Henk’s answer, you need: string rootFolderPath = @”C:\\SomeFolder\\AnotherFolder\\FolderCOntainingThingsToDelete”; string filesToDelete = @”*DeleteMe*.doc”; // Only delete DOC files containing “DeleteMe” in their filenames string[] fileList = System.IO.Directory.GetFiles(rootFolderPath, filesToDelete); foreach(string file in fileList) { System.Diagnostics.Debug.WriteLine(file + “will be deleted”); // System.IO.File.Delete(file); } BE VERY CAREFUL! Note that I’ve commented out the delete command. Run … Read more

Expand tilde in Rust Path idiomatically

The most idiomatic way would be to just use an existing crate, in this case shellexpand (github, crates.io) seems to do what you want: extern crate shellexpand; // 1.0.0 #[test] fn test_shellexpand() { let home = std::env::var(“HOME”).unwrap(); assert_eq!(shellexpand::tilde(“~/foo”), format!(“{}/foo”, home)); } Alternatively, you could try it with dirs (crates.io). Here is a sketch: extern crate … Read more

tech