Difference between revisions of "Issue:Find unused files"
m (→Work around) |
|||
(3 intermediate revisions by 2 users not shown) | |||
Line 24: | Line 24: | ||
== Reply == | == Reply == | ||
The problem is that <tt>notlinksfrom</tt> expects an exact article name; it does not understand 'LIKE %'. | The problem is that <tt>notlinksfrom</tt> expects an exact article name; it does not understand 'LIKE %'. | ||
+ | |||
+ | == Work around == | ||
+ | |||
+ | You can nest two queries; the first one produces a list of all images and calls another template for each ofg the images. The second query produces output only if the <tt>imageused</tt> clause is false. | ||
+ | |||
+ | <pre><nowiki> | ||
+ | ---------------------------------------- Code in a page named 'check list for unused images' (e.g.) | ||
+ | ===Unused Images=== | ||
+ | {{#dpl: | ||
+ | |namespace=Image | ||
+ | |format=,²{Unused Image¦%PAGE%}², | ||
+ | |count=100 | ||
+ | }} | ||
+ | ---------------------------------------- Code in page 'Template:Unused Image' | ||
+ | {{#replace: | ||
+ | {{#dpl: | ||
+ | |imageused={{{1}}} | ||
+ | |resultsheader=OOKK | ||
+ | |noresultsheader=\n* [[{{{1}}}]] | ||
+ | }}|/.*OOKK.*/| | ||
+ | }} | ||
+ | ---------------------------------------- end | ||
+ | </nowiki></pre> | ||
+ | |||
+ | The code in the second template generates the lsit of articles which use an image; the #replace throws the whole list away if there was at least one match; otherwise it outputs the name of the image under question. | ||
+ | |||
+ | [[User:Gero|Gero]] 21:20, 1 May 2009 (UTC) | ||
+ | :Oh thanks for the code. It returns the pages it checked as well. But those links which are images are really unused. [http://www.mixesdb.com/db/index.php/MixesDB:Tests/Unused_Images Link] (will remove my link after next reply). | ||
+ | :Ok so I guessed right that there is no standard way to return unlinked pages (pages which are not linked to on other pages)? What about a new format symbol for that? There is the BOOL page.il_to, so it should be easy query. E.g. | ||
+ | <pre>{{dpl: | ||
+ | |namespace=File | ||
+ | |format=,%UNLINKED% | ||
+ | }}</pre> | ||
+ | :Result: All unused image pages. --[[User:Subfader|Subfader]] 21:44, 1 May 2009 (UTC) |
Latest revision as of 23:13, 1 May 2009
Description: | Return unused files |
Extension / Version: | DPL / ? |
Type / Status: | Change Request / open |
Problem
Is there a way to select images that are used (il_to NOT NULL, linked to by any other page)) or unsed?
I want to return a simple list of unused images, but also in combination, e.g. unused files, uploaded by a specifed user.
This should actually return a simple list of 5 unused files (if I understand the parameter correctly), but it doesn't.
{{#dpl: |debug=3 |namespace=Image |notlinksfrom=% |count=5 }}
- File:12345.JPG
- File:20070713 DynamicPageList2.zip
- File:20070718 DynamicPageList2.zip
- File:20071227 DPL calendar has error.png
- File:20071227 DPL calendar has no error-1.png
Reply
The problem is that notlinksfrom expects an exact article name; it does not understand 'LIKE %'.
Work around
You can nest two queries; the first one produces a list of all images and calls another template for each ofg the images. The second query produces output only if the imageused clause is false.
---------------------------------------- Code in a page named 'check list for unused images' (e.g.) ===Unused Images=== {{#dpl: |namespace=Image |format=,²{Unused Image¦%PAGE%}², |count=100 }} ---------------------------------------- Code in page 'Template:Unused Image' {{#replace: {{#dpl: |imageused={{{1}}} |resultsheader=OOKK |noresultsheader=\n* [[{{{1}}}]] }}|/.*OOKK.*/| }} ---------------------------------------- end
The code in the second template generates the lsit of articles which use an image; the #replace throws the whole list away if there was at least one match; otherwise it outputs the name of the image under question.
Gero 21:20, 1 May 2009 (UTC)
- Oh thanks for the code. It returns the pages it checked as well. But those links which are images are really unused. Link (will remove my link after next reply).
- Ok so I guessed right that there is no standard way to return unlinked pages (pages which are not linked to on other pages)? What about a new format symbol for that? There is the BOOL page.il_to, so it should be easy query. E.g.
{{dpl: |namespace=File |format=,%UNLINKED% }}
- Result: All unused image pages. --Subfader 21:44, 1 May 2009 (UTC)