MENU

Fun & Interesting

Automate file management in R with the {fs} package

R for the Rest of Us 973 4 weeks ago
Video Not Working? Fix It Now

CODE AND DESCRIPTION In this video, Jadey Ryan shows you how to use the {fs} package to easily organize chaotic folders full of files with inconsistent names. Jadey demonstrates how to rename, create, move, and delete files with just a few lines of code, turning disorganized chaos into clean, consistent order! You can find all of the code in the corresponding blog post at https://rfortherestofus.com/2025/01/fs-file-management If you want to receive emails to help you on your R journey, sign up for the R for the Rest of Us newsletter: https://rfortherestofus.com/newsletter Chapters 0:00 - Intro 01:04 - Objective and loading packages 02:00 - Using dir_create() and dir_exists() to verify folder existence 04:46 - Using dir_tree() to visualize folder structure 05:33 - Standardizing names: Using dir_ls() to list files and stringr for kebab-case renaming 07:06 - file_move() applied to old and new file names 08:38 - Creating subdirectories (folders for file organization) 09:30 - Moving files to subdirectories 11:58 - Using dir_tree() to confirm organized file structure 12:26 - Using dir_delete() to remove example folder and dir_exists() to verify 13:23 - Creating custom functions to automate organization 16:14 - Final check: Confirm organization with dir_tree() 17:01 - Conclusion: Benefits of automation for file naming and organization 17:15 - Outro

Comment