Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
file_renaming [2023/08/05 03:47] – created dstillmanfile_renaming [2024/02/19 07:26] (current) – [Variables] tnajdek
Line 29: Line 29:
 The following variables and parameters are supported: The following variables and parameters are supported:
  
-  * TODO+==== Variables ====
  
-The ''suffix'' parameter is supported on all variables.+^ Variable ^ Description ^ 
 +| ''authors'' | Parent item's principal creators (depending on the item type these are authors or artists but not editors or other contributors). | 
 +| ''editors'' | Parent item's editors. | 
 +| ''creators'' | All parent item's creators. | 
 +| ''firstCreator'' | Parent item's creator (1–2 authors or editors). | 
 +| ''itemType'' | Parent item type. | 
 +| ''year'' | Year, extracted from parent item's date field. | 
 +| Any item field | Complete list of fields can be found at the bottom of this page. | 
 + 
 + 
 +If a variable value starts or ends with a space, which is likely to happen when used in conjunction with the ''truncate'' parameter, these spaces are removed from the filename. 
 +==== Parameters ==== 
 +^ Parameter ^ Variables ^ Default Value ^ Description ^ 
 +| ''truncate'' | All |  | Truncates variable value at fixed number of characters, e.g, ''%%{{ title truncate="20" }}%%'' will be replaced with the first 20 characters of parent item's title. Truncation happens after every other parameter has been applied, except for ''prefix'', ''suffix'' and ''case''. | 
 +| ''prefix'' | All |  | Prepends variable with given character(s), e.g., ''%%{{ title prefix="title" }}%%'' will be replaced by the word “title” followed by parent item's title. If variable is empty (e.g., item's parent has empty title), entire statement, including prefix, is ignored. | 
 +| ''suffix'' | All |  | Appends given character(s) at the end of a variable with, e.g., ''%%{{ title suffix="!" }}%%'' will be replaced by parent item's title followed by an exclamation mark. If variable is empty (e.g., item's parent has empty title), entire statement, including suffix, is ignored. | 
 +| ''case'' | All |  | Converts case of a variable, following values are accepted:  ''upper'', ''lower'', ''sentence'', ''title'', ''hyphen'', ''snake'', ''camel''. E.g., ''%%{{ title case="snake" }}%%'' will result in ''title_written_like_this'' in the file name. | 
 +| ''max'' | ''authors'', ''editors'', ''creators'' |  | Limits number of creators to use, e.g., ''%%{{ editors max="1" }}%%'' will be replaced with first editor of parent's item. | 
 +| ''name'' | ''authors'', ''editors'', ''creators'' | ''family'' | Customizes how creator name appears in the filename, with the following accepted options: ''family-given'' will use full name of the creator, beginning with family (last) name of the creator, ``given-family`` also uses full name but inverts the order, and options ` ''given'' and ''family'' will only use part of the parent item's creator's name. | 
 +| ''name-part-separator'' | ''authors'', ''editors'', ''creators'' | '' ''(single space character) | Defines what characters to use to separate given and family name, especially useful when combined with ''initialize''. | 
 +| ''join'' | ''authors'', ''editors'', ''creators'' | '', '' | Defines what characters to use to separate consecutive creators. | 
 +| ''initialize'' | ''authors'', ''editors'', ''creators'' | | Enables use of initials for part or whole of creators name, with the following accepted options: ''full'' will use initials for the entire name, ''given'' and ''family'' will only use initials for that part of the name. Order of name parts is controlled by ''name'' parameter and only parts included by ''name'' parameter can be converted to initials. E.g. ''%%{{ authors name="given-family" initialize="given" }}%%'' will be replaced by a comma-separated list of authors, where each author's given name is replaced with an initial, followed by a dot and a space (e.g. ''J. Smith, D. Jones''). | 
 +| ''initialize-with'' | ''authors'', ''editors'', ''creators'' | ''.'' | Controls what character is appended to the initial, if name part was initialized. | 
 +| ''localize'' | ''itemType'' | | Whether to use localized value of the item type variable, e.g., ''%%{{ itemType localize="true" }}%%'' will be replaced by parent item's type spelled in the language Zotero is using. | 
 + 
 +==== Examples ==== 
 + 
 +A year of publication, followed by a hyphen-separated list of authors, followed by a title truncated at 30 characters: 
 + 
 +Template: ''%%{{ year suffix="-" }}{{ authors name="family-given" initialize="given" initialize="-" join="-" suffix="-" case="hyphen" }}{{ title truncate="30" case="hyphen" }}%%'' 
 + 
 +Filename: ''2023-lee-sukbae-kim-ji-hoon-kwon-young-wan-the-first-room-temperature-amb.pdf'' 
 + 
 +Anything not included inside a ''%%{{%%'' bracket is copied to the filename literally: 
 + 
 +Template: ''%%{{ itemType localize="true" }} from {{ year }} by {{ authors max="1" name="given-family" initialize="given" }}%%'' 
 + 
 +Filename: ''Preprint from 2023 by S. Lee.pdf'' 
 + 
 +Templates also support conditionals, certain part of the template can be included or excluded using a combination of ''if'', ''elseif'', ''else''. Condition must end with ''endif''. Template below will use DOI for journal articles and preprints, ISBN for books and title for any other item type: 
 + 
 +''%%{{ if itemType == "book" }}{{ISBN}}{{ elseif itemType == "preprint" }}{{ DOI }}{{ elseif itemType == "journalArticle" }}{{ DOI }}{{ else }}{{ title }}{{ endif }}%%'' 
 + 
 + 
 +==== Complete List of Fields ==== 
 + 
 +  * ''abstractNote'' 
 +  * ''accessDate'' 
 +  * ''applicationNumber'' 
 +  * ''archive'' 
 +  * ''archiveID'' 
 +  * ''archiveLocation'' 
 +  * ''artworkMedium'' 
 +  * ''artworkSize'' 
 +  * ''assignee'' 
 +  * ''audioFileType'' 
 +  * ''audioRecordingFormat'' 
 +  * ''billNumber'' 
 +  * ''blogTitle'' 
 +  * ''bookTitle'' 
 +  * ''callNumber'' 
 +  * ''caseName'' 
 +  * ''citationKey'' 
 +  * ''code'' 
 +  * ''codeNumber'' 
 +  * ''codePages'' 
 +  * ''codeVolume'' 
 +  * ''committee'' 
 +  * ''company'' 
 +  * ''conferenceName'' 
 +  * ''country'' 
 +  * ''court'' 
 +  * ''date'' 
 +  * ''dateDecided'' 
 +  * ''dateEnacted'' 
 +  * ''dictionaryTitle'' 
 +  * ''distributor'' 
 +  * ''docketNumber'' 
 +  * ''documentNumber'' 
 +  * ''DOI'' 
 +  * ''edition'' 
 +  * ''encyclopediaTitle'' 
 +  * ''episodeNumber'' 
 +  * ''extra'' 
 +  * ''filingDate'' 
 +  * ''firstPage'' 
 +  * ''format'' 
 +  * ''forumTitle'' 
 +  * ''genre'' 
 +  * ''history'' 
 +  * ''identifier'' 
 +  * ''institution'' 
 +  * ''interviewMedium'' 
 +  * ''ISBN'' 
 +  * ''ISSN'' 
 +  * ''issue'' 
 +  * ''issueDate'' 
 +  * ''issuingAuthority'' 
 +  * ''journalAbbreviation'' 
 +  * ''label'' 
 +  * ''language'' 
 +  * ''legalStatus'' 
 +  * ''legislativeBody'' 
 +  * ''letterType'' 
 +  * ''libraryCatalog'' 
 +  * ''manuscriptType'' 
 +  * ''mapType'' 
 +  * ''meetingName'' 
 +  * ''nameOfAct'' 
 +  * ''network'' 
 +  * ''numPages'' 
 +  * ''number'' 
 +  * ''numberOfVolumes'' 
 +  * ''organization'' 
 +  * ''pages'' 
 +  * ''patentNumber'' 
 +  * ''place'' 
 +  * ''postType'' 
 +  * ''presentationType'' 
 +  * ''priorityNumbers'' 
 +  * ''proceedingsTitle'' 
 +  * ''programTitle'' 
 +  * ''programmingLanguage'' 
 +  * ''publicLawNumber'' 
 +  * ''publicationTitle'' 
 +  * ''publisher'' 
 +  * ''references'' 
 +  * ''reportNumber'' 
 +  * ''reportType'' 
 +  * ''reporter'' 
 +  * ''reporterVolume'' 
 +  * ''repository'' 
 +  * ''repositoryLocation'' 
 +  * ''rights'' 
 +  * ''runningTime'' 
 +  * ''scale'' 
 +  * ''section'' 
 +  * ''series'' 
 +  * ''seriesNumber'' 
 +  * ''seriesText'' 
 +  * ''seriesTitle'' 
 +  * ''session'' 
 +  * ''shortTitle'' 
 +  * ''status'' 
 +  * ''studio'' 
 +  * ''subject'' 
 +  * ''system'' 
 +  * ''thesisType'' 
 +  * ''title'' 
 +  * ''type'' 
 +  * ''university'' 
 +  * ''url'' 
 +  * ''versionNumber'' 
 +  * ''videoRecordingFormat'' 
 +  * ''volume'' 
 +  * ''websiteTitle'' 
 +  * ''websiteType''
file_renaming.1691221656.txt.gz · Last modified: 2023/08/05 03:47 by dstillman