Folder Renaming using Dynamo or Python

Hi guys,

I am looking for a package or if there’s anything out there that is similar to the File.Rename node from the Orchid package but I need one for a Folder.Rename if there’s any?

I have tried several methods including moving the move file node and deleting the folders later.
Just haven’t had much success.

My python skills are pretty subpar at the moment so rebuilding one is going to take a long time. I can’t find any reference for the import os method.

this is my current work in progress.

# Load the Python Standard and DesignScript Libraries
import sys
import clr
import os

# The inputs to this node will be stored as a list in the IN variables.
foldername = IN[0]
newfoldername = IN[1]

# Place your code below this line
os.chdir(foldername)
folders=os.listdir(foldername)

for i in range (len(folders)):
	os.rename(folders[i], newfoldername)

# Assign your output to the OUT variable.
OUT = 0

Appreciate the help I can get for this from any legends here.

Cheers,
J Lee

Hi @jasonlkw and welcome…think you can do it with OOTB nodes…

Screenshot 2021-11-01 200911

1 Like

Hi Sovitek,

Oh hey! that actually worked! I thought I had to delete it with a passthrough linked to the solution.

Just out of curiosity though, is there a python solution out there?
The import os method does add a lot of possibilities too so I’d like to understand a bit more on that context.

Cheers mate :slight_smile:

1 Like

https://www.tutorialspoint.com/python/os_rename.htm

2 Likes

Anyway really take care is the right path you wanna move,because the node do what it say…with any warnings…specially if you use override…

1 Like

Understood mate. I am currently optimizing the graph and adding security layers to ensure errors can be avoided.

It sort of involves optimizing a certain amount of data in my current folders and system to make this more efficient.

Helped a lot nonetheless. Cheers.

The python method will take a bit of work so thanks for that aaron!

1 Like