Modifying File Path String and Batch PDF Renaming

bakery
revit
dynamo
clockwork

#1

Hello Everyone,

I have recently been trying to solve a PDF renaming task with Dynamo. Currently Revit is automatically generating a file name for hundreds of PDF’s we are printing. The current format is, FRIEDMAN_CENTRAL_R17_ALucree - Sheet - G004 - CODE DATA.PDF, our desired format is, G004 - CODE DATA_18-05-04.PDF. As you can see there is also a print date which I think is as easy as adding a date and time node. I am not looking for the whole answer to the problem here because I am new to Dynamo and think this is a good exercise but I am currently stuck on this. In my script I used a Unique Identifier to break the list into pieces and recombine it in the correct format. Currently I would have to do this for every file but I bet there is a way to have Dynamo scan the folder for PDF’s and rename the files in the correct format one at a time. Any help would be greatly appreciated and once again very new to Dynamo so go easy on me.

Thanks!!
Renaming%20File%20Path%20Script|690x170


#2

Sorry this is probably a better example image


#3

Look into the following nodes:

Directory.Contents
String.Replace
String from object
+

First is an out of the box node that I recommend over the custom one you’re using.

Second can replace part of a string (say the bad part of the file name) with a new string (even if the string has no characters in it).

Third will convert objects to strings so you can manipulate them.

Fourth will add stuff. Numbers comes to mind but strings work as well.

Good luck and welcome to the community. :smiley:


#4

For the end of the graph, you can use “Rename Files” node from archilab package or “Rename” from Orchid package.

P.S : If you print the pdf with Dynamo, you will not necessarily have to rename your pdf files.


#5

This is true, but the concepts in renaming are really good to know, and printing can’t fix those pesky consultant PDFs either, so I’d save printing for a future endeavor. :slight_smile:


#7

Hi Everyone,

A quick update, Ive got my script to the point where I am passing the correct names to the archi-lab rename files node and it is acting a bit strange. Every time I run the script it renames only one of the pdf’s but does not format it with the correct name or the .pdf extension. It renames it with a Capital letter G. Can anyone spot my mistake? I am receiving a trace!back error stating the file already exists.


Thank you,
Kyle


#8

Hi,
Don’t know if you still need this, but here is solution: