Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How to name files, the sequel

How to name files, the sequel

Low-tech common sense about filenames. Recorded as a lightning talk at NormConf (https://normconf.com), December 2022.

Lightning talk on YouTube: https://youtu.be/ES1LTlnpLMk

More resources, credits, etc. available at:
- https://pos.it/how-to-name-files
- https://github.com/jennybc/how-to-name-files

Based on an earlier set of slides from 2014/2015 (https://speakerdeck.com/jennybc/how-to-name-files).

Jennifer (Jenny) Bryan

December 04, 2022
Tweet

More Decks by Jennifer (Jenny) Bryan

Other Decks in Programming

Transcript

  1. How to Name Files
    Like a Normie
    pos.it/how-to-name-
    fi
    les
    Jenny Bryan

    Posit, PBC

    t
    @JennyBryan

    g
    @jennybc

    m
    @[email protected]

    View Slide

  2. Check out Jason Bourne, 6 minutes in!

    View Slide

  3. Pick a filename convention
    Any convention
    Just pick one

    View Slide

  4. myabstract.docx


    Jane’s Filenames Use “Spaces” & Punctuation ;).xlsx


    figure 1.png


    JW7d^(2sl@deletethisandyourcareerisoverWx2*.txt
    2022-09-24_abstract-for-normconf.docx


    janes-filenames-are-getting-better.xlsx


    fig01_scatterplot-talk-length-vs-interest.png


    1986-01-28_raw-data-from-challenger-o-rings.txt
    YES
    NO

    View Slide

  5. good file names are ...
    • machine readable
    • human readable
    • sorted in a useful way

    View Slide

  6. > ls


    2013-06-26_BRAFWTNEGASSAY_Plasmid-Cellline-100-1MutantFraction_A01.csv


    ...


    2013-06-26_BRAFWTNEGASSAY_Plasmid-Cellline-100-1MutantFraction_H02.csv


    2013-06-26_BRAFWTNEGASSAY_Plasmid-Cellline-100-1MutantFraction_H03.csv


    2013-06-26_BRAFWTNEGASSAY_Plasmid-Cellline-100-1MutantFraction_platefile.csv


    2014-02-26_BRAFWTNEGASSAY_FFPEDNA-CRC-1-41_A01.csv


    2014-02-26_BRAFWTNEGASSAY_FFPEDNA-CRC-1-41_A02.csv


    2014-02-26_BRAFWTNEGASSAY_FFPEDNA-CRC-1-41_A03.csv


    ...


    > ls *Plasmid*


    2013-06-26_BRAFWTNEGASSAY_Plasmid-Cellline-100-1MutantFraction_A01.csv


    ...


    2013-06-26_BRAFWTNEGASSAY_Plasmid-Cellline-100-1MutantFraction_H02.csv


    2013-06-26_BRAFWTNEGASSAY_Plasmid-Cellline-100-1MutantFraction_H03.csv


    2013-06-26_BRAFWTNEGASSAY_Plasmid-Cellline-100-1MutantFraction_platefile.csv
    globbing

    View Slide

  7. tibble(filenames) |>


    separate_wider_delim(


    filenames,


    delim = regex("[_\\.]"),


    names = c("date", "assay", "line", "well", NA)


    )


    #> # A tibble: 25 × 4


    #> date assay line well


    #>


    #> 1 2013-06-26 BRAFWTNEGASSAY Plasmid-Cellline-100-1MutantFraction A01


    #> 2 2013-06-26 BRAFWTNEGASSAY Plasmid-Cellline-100-1MutantFraction A02


    #> 3 2013-06-26 BRAFWTNEGASSAY Plasmid-Cellline-100-1MutantFraction A03


    ...
    2014-02-26_BRAFWTNEGASSAY_FFPEDNA-CRC-1-41_A03.csv
    _ Underscore to delimit
    fi
    elds

    - Hyphen to delimit words within
    fi
    elds
    regular expressions

    View Slide

  8. Thou shalt get only as
    creative with names as
    thine own skill with
    regular expressions.

    View Slide

  9. machine readable
    • regular expression and globbing friendly

    - avoid spaces, punctuation, accented characters, case sensitivity

    • easy to compute on

    - deliberate use of delimiters

    View Slide

  10. 01.md


    01.R


    02.md


    02.R


    03.md


    03.R


    04.md


    04.R


    9.md


    90.R


    figure/


    helpers.R


    Makefile
    01_marshal-data.md


    01_marshal-data.R


    02_pre-dea-filtering.md


    02_pre-dea-filtering.R


    03_dea-with-limma-voom.md


    03_dea-with-limma-voom.R


    04_explore-dea-results.md


    04_explore-dea-results.R


    90_limma-model-term-name-fiasco.md


    90_limma-model-term-name-fiasco.R


    figure/


    helper01_load-counts.R


    helper02_load-exp-des.R


    helper03_load-focus-statinf.R


    helper04_extract-and-tidy.R


    Makefile

    View Slide

  11. embrace the slug
    01_marshal-data.R


    02_pre-dea-filtering.R


    03_dea-with-limma-voom.R


    04_explore-dea-results.R

    View Slide

  12. human readable
    • make it easy to guess what the heck something is,
    based on its name

    View Slide

  13. 01_marshal-data.R


    02_pre-dea-filtering.R


    03_dea-with-limma-voom.R


    04_explore-dea-results.R


    90_limma-model-term-name-fiasco.R


    figure/


    helper01_load-counts.R


    helper02_load-exp-des.R


    helper03_load-focus-statinf.R


    helper04_extract-and-tidy.R


    Makefile
    2015-11-09_package-installation.R


    2015-12-23_package-installation.R


    2016-05-21_package-installation.R


    2016-07-30_package-installation.R


    2017-09-05_package-installation.R


    2018-06-29_package-installation.R


    2019-02-19_repair-default-library.R


    2019-06-25_package-installation.R


    2020-06-06_record-existing-pkgs.R


    2021-06-15_git-config-analysis.R


    2021-07-19_fix-https-git-urls.R


    2021-08-29_git-default-branch-analysis.R


    2022-08-11_rebuilding-my-user-library.R


    2022-08-11_record-existing-pkgs.R
    chronological
    logical

    View Slide

  14. 10_final-figs-for-publication.R


    1_data-cleaning.R


    2_fit-model.R


    ...
    01_data-cleaning.R


    02_fit-model.R


    ...


    10_final-figs-for-publication.R
    YES
    NO

    View Slide

  15. Comprehensive
    map of all countries
    in the world that
    use MM-DD-YYYY
    https://twitter.com/donohoe/status/597876118688026624

    View Slide

  16. ISO 8601
    for the love of god, please
    2022-12-15

    View Slide

  17. sorted in a useful way
    •plan for alphanumeric sorting

    •put something numeric-ish
    fi
    rst-ish

    •use the ISO 8601 standard for dates

    •left pad numbers with zeros

    View Slide

  18. good file names are ...
    • machine readable
    • human readable
    • sorted in a useful way
    pos.it/how-to-name-
    fi
    les

    t
    @JennyBryan

    g
    @jennybc

    m
    @[email protected]

    View Slide