Rename a folder with files in it

32 views (last 30 days)
nicholas tuminello
nicholas tuminello on 19 Mar 2021
Answered: Cris LaPierre on 19 Mar 2021
Hello, I was trying to rename folder using movefile() function but realised that it only works on empty folders.
Is there anyway to rename this folder with files in it?
oldfolderdir = "c:\temp\oldfoldername_withstuffinit"
newfolderdir = "C:\temp\newfoldername_withstufffrom_oldfoldername"
movefile oldfolder newfolder

Answers (1)

Cris LaPierre
Cris LaPierre on 19 Mar 2021
The movefile function can rename folders with files in them (I just tested on a folder on my computer) but it does depend on the write permissions you have. You can try using the following syntax for locations that are not writable.

Categories

Find more on Search Path in Help Center and File Exchange

Products


Release

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!