Skip to content

Script for deleting Files with No Global Usage#6

Closed
iamentry wants to merge 2 commits intomasterfrom
delete-ngu
Closed

Script for deleting Files with No Global Usage#6
iamentry wants to merge 2 commits intomasterfrom
delete-ngu

Conversation

@iamentry
Copy link
Collaborator

@iamentry iamentry commented Jul 8, 2025

This is a script FO wrote for me a while back that allows to easily delete files on Commons that have no usage across the wikis. I've only ever used it on Category:Unknown License as a way to make checking usage easier when I went on deletion runs.

The addition of this code is the only change from the normal deletion script:

        """Skip files with global usage"""
        if not self.opt.undelete and page.exists() and page.namespace() == Namespace.FILE:
            global_usage = page.site.simple_request(action='query', prop='globalusage', titles=page.title()).submit()
            if len(global_usage['query']['pages'][str(page.pageid)]['globalusage']) > 0:
                pywikibot.info(f'Skipping: {page} has global usage.')
                return True

Copy link
Collaborator

@hjpalpha hjpalpha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo add it into delete.py

@iamentry
Copy link
Collaborator Author

iamentry commented Jul 8, 2025

imo add it into delete.py

As a param? I'm not quite sure how to

@hjpalpha
Copy link
Collaborator

hjpalpha commented Jul 9, 2025

imo add it into delete.py

As a param? I'm not quite sure how to

personally i would envision a param ala -checkfilesforglobalusage (if someone has something shorter go for it)
and then if that param is set you add the check you mentioned in the summary

you could take the open/closed prs as examples

if you need help with it lmk, i can look into it when i have some time inbetween meetings etc in the next days/weeks
(after i finished the infobox standardization (outside of dota2))

@mbergen
Copy link
Collaborator

mbergen commented Jul 9, 2025

personally i would envision a param ala -checkfilesforglobalusage (if someone has something shorter go for it)

Is there a good reason not to remove the namespace check and call it -checkglobalusage?

Could also think about whether we just want to have it on by default and a flag to disable it.

@hjpalpha
Copy link
Collaborator

hjpalpha commented Jul 9, 2025

personally i would envision a param ala -checkfilesforglobalusage (if someone has something shorter go for it)

Is there a good reason not to remove the namespace check and call it -checkglobalusage?

yeah was thinking about that too
might be a good idea

Could also think about whether we just want to have it on by default and a flag to disable it.

if we do that limit it to commons
like if you do a deletion run on a wiki you just do not care about global usage :P

@mbergen
Copy link
Collaborator

mbergen commented Jul 9, 2025

if we do that limit it to commons
like if you do a deletion run on a wiki you just do not care about global usage :P

We could check local usage in these cases - however there are not many occasions for non-commons bot deletions, right?

@hjpalpha
Copy link
Collaborator

hjpalpha commented Jul 9, 2025

if we do that limit it to commons
like if you do a deletion run on a wiki you just do not care about global usage :P

We could check local usage in these cases - however there are not many occasions for non-commons bot deletions, right?

not often, no
mostly when nuking redirects into user space

@hjpalpha
Copy link
Collaborator

superseded by #7

@hjpalpha hjpalpha closed this Nov 24, 2025
@hjpalpha hjpalpha deleted the delete-ngu branch November 24, 2025 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants