Created
August 8, 2024 21:13
-
-
Save Beyarz/a4de39a45d557d81479bb93147bc7442 to your computer and use it in GitHub Desktop.
Rename every folder in a directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# Put me in a folder where you want to bulk rename every folder | |
# In this case, this script will rename every folder from "Photos from YEAR" to "YEAR" only | |
# Run: ruby bulk_rename.rb | |
folders = Dir.entries('.').reject { ['.', '..'].include? _1 } | |
folders.each do |folder| | |
File.rename(File.join(Dir.pwd, folder), File.join(Dir.pwd, folder.delete_prefix("Photos from "))) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment