Skip to content

Script to find and delete unused images - #3938

Open
Patrick Brosset (captainbrosset) wants to merge 2 commits into
mainfrom
user/pabrosse/delete-unused-images
Open

Script to find and delete unused images#3938
Patrick Brosset (captainbrosset) wants to merge 2 commits into
mainfrom
user/pabrosse/delete-unused-images

Conversation

@captainbrosset

Copy link
Copy Markdown
Contributor

This PR adds scripts/find-unused-images.js, a script which scans the "microsoft-edge" folder for "*-images" folders (each one holding the screenshots/pictures used by the article that shares its base name, e.g. "focus.md" -> "focus-images/") and detects image files inside them that are not referenced from their matching sibling article.

By default this runs in "dry run" mode and only prints a report of the unused images it finds. Pass --delete to actually delete them.

Usage:

  • To find and list unused images, without deleting them: node scripts/find-unused-images.js
  • To find unused images, and delete them: node scripts/find-unused-images.js --delete

Assumptions:

  • Every "-images" folder is expected to sit right next to its matching ".md" article, in the same directory (e.g. "focus.md" and "focus-images/" are siblings).
  • An image is considered "used" only if its filename (case-insensitive) is referenced from that one matching article file. A reference to an image of the same name from a different article does NOT count as "used" - each images folder is checked strictly against its own sibling article.
  • If no matching ".md" article exists next to a "-images" folder, every image inside that folder is reported as unused (there is no article that could be using them).

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 5e53ae6:

✅ Validation status: passed

File Status Preview URL Details
scripts/find-unused-images.js ✅Succeeded

For more details, please refer to the build report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cat: general General content.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants