Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rename a directory?

Tags:

file-io

ruby

How do I rename a directory in Ruby?
I see how to rename individual files, but not folders.

like image 872
dylam Avatar asked Jul 18 '11 20:07

dylam


People also ask

How do I rename a directory in command prompt?

Use the ren or rename command to rename the directory. Because you cannot have a file and directory of the same name, you don't need to worry about mistakenly renaming a file instead of a directory. The only exception is if you're using wild characters.

How do I rename a directory in git?

To rename any file or folder, use git mv command which takes two arguments. The first argument is the source and the second is the destination. We can easily rename any file using the git command and the new name will be assigned to that file. We can rename the file using GitHub or the command line.

How do you rename a folder in Windows?

To rename files and folders in Windows 11 using File Explorer, select the file or folder to rename within the File Explorer window. Then click the “Rename” button in the Ribbon at the top of the window. Doing this then highlights the name of the currently selected file or folder and places a thin border around it.


2 Answers

FileUtils.mv old_name, new_name

Check the docs for more info

like image 178
diedthreetimes Avatar answered Oct 10 '22 21:10

diedthreetimes


File.rename will let you rename directories:

File.rename './my-directory', './my-renamed-directory'
like image 34
mipadi Avatar answered Oct 10 '22 20:10

mipadi