Skip to content

? Illustrate Potentially Useful Commands

abhro edited this page Sep 30, 2025 · 6 revisions

If you use WSL2 in Windows, "Zone Identifier" files are often created and can be deleted. The Julia walkdir command walks through all the directory's folders to find and delete these files. The few lines also illustrate try catch.

"""     #(indicates Julia docstring)

Recursively search through the specified directory and delete all Windows Zone.Identifier files.

These files are created by Windows when downloading files from the internet and contain metadata about the file's origin. They are typically not needed on other operating systems and can be safely removed.

Arguments
- `dir::String`: The root directory path to start the search from

Notes
- Function will print confirmation messages for each deleted file
- Errors during deletion are caught and reported but don't halt execution

"""
function delete_zone_identifier_files(dir::String)
    for (root, dirs, files) in walkdir(dir)
        for file in files
            if endswith(file, ":Zone.Identifier")
                filepath = joinpath(root, file)
                try
                    rm(filepath)
                    println("Deleted: $filepath")
                catch e
                    println("Error deleting $filepath: $e")
                end
            end
        end
    end
end

Specify the directory to search: target_directory = "path to directory"; call the function to delete the files:

delete_zone_identifier_files(target_directory)

Clone this wiki locally