Shell Script to Rename Folder and Create New Folder

Hello all. I’m looking for a little guidance for an idea I have that is pretty straightforward I think but I’m not overly familiar with scripting.


I’m thinking of a shell script (I can use launchd to run on a monthly basis) that takes folder

`/Users/nathan/Kometa/config/assets`, rename it to `/Users/nathan/Kometa/config/assets2` (leaving contents intact), then recreates the empty original assets directory. How would I go about that?


What does “monthly” look like in terms of a launchd calendar interval?


Thanks!

Mac mini, macOS 14.7

Posted on Feb 27, 2025 9:33 PM

Reply
2 replies
Sort By: 

Feb 28, 2025 7:06 AM in response to rothnd

I think I've got the bones. Basically a sh that mv assets assets2 then mkdir assets. Run on a launchd Day1, Hour1, Min1 (every month on the first at 1?).


Question now is I would like to incorporate some level of, simple, logging of this script just so I can see when it ran, what it ran, etc. But I have 0 experience with logging, could use some help there.

Reply

Feb 28, 2025 7:28 AM in response to rothnd

Ughhhh. I stand corrected. When I manually invoke this in terminal it works fine but when invoked by launchd I get 'mv rename operation not permitted' in stdout... I've tried giving Terminal Full Disk Access and now trying mv command with sudo.

Reply

Shell Script to Rename Folder and Create New Folder

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.