# Help with renaming multiple pdf files - First Dynamo graph

**URL:** <https://forum.dynamobim.com/t/help-with-renaming-multiple-pdf-files-first-dynamo-graph/12028>\
**Category:** Uncategorized\
**Created:** [May 25, 2017, 1:52pm UTC](https://forum.dynamobim.com/t/help-with-renaming-multiple-pdf-files-first-dynamo-graph/12028 "2017-05-25T13:52:54Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![DeanB72](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@DeanB72](https://forum.dynamobim.com/u/DeanB72)\
**Post date:** [May 25, 2017, 1:52pm UTC](https://forum.dynamobim.com/t/help-with-renaming-multiple-pdf-files-first-dynamo-graph/12028/1 "2017-05-25T13:52:54Z")

</div>

Hi… I’m an absolute beginner in Dynamo so not exactly sure of the ways that it is going to help me but I can see the potential is there to be unlocked if I can pick up some skills.

I am a Revit technician (Structural) and have a need to improve Revit’s limited pdf creation tools and following various online research and painstaking baby steps I have written my first Dynamo Graph which does do what I need but in quite a basic way, but I would appreciate some simple guidance on how I can get over a hurdle as follows…

I sometimes work on projects that have strict naming conventions for issued pdf files, which are a bit of a pain to change manually so have written a graph to do it for me. At the moment I have got it set to rename five files as that’s how many I am using in my test set up, but obviously each project may have a different number of sheets therefore I am wondering what my options are for building into my graph some way of Dynamo working out how many files it needs to rename ?

I’m guessing this is obvious to experienced users but with my basically non-existent Dynamo/Programming experience, I have no idea what to look for beyond this point in my graph. I understand that this problem may have been solved/discussed many times in the past but if I just copy what someone else has created I won’t learn a thing so I wanted to try to solve the problem as much as I could.

Does anyone have any suggestions ?

Thanks

This is a screenshot of my graph (assuming I have uploaded correctly)…

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/c/9ce2207f1cf9459b3ef1433ed4614cca0bba377e.PNG)

---

<div class="post-metadata">

**Author:** ![jksmith1992](https://avatars.discourse-cdn.com/v4/letter/j/c4cdca/32.png) [@jksmith1992](https://forum.dynamobim.com/u/jksmith1992)\
**Post date:** [May 25, 2017, 2:37pm UTC](https://forum.dynamobim.com/t/help-with-renaming-multiple-pdf-files-first-dynamo-graph/12028/2 "2017-05-25T14:37:17Z")

</div>

Hi DeanB72

Could you get the information you need for the new name from parameters within the project? i.e Sheet Number, sheet name, current revision.

If so then I recommend reading Konrad’s blog (link below)

> **[printing PDFs w/ dynamo](http://archi-lab.net/printing-pdfs-w-dynamo/)**
>
> Some time ago I have spotted this post by Sol Armor at DynamoBIM forum, asking about printing PDFs out of Dynamo and I was a little sad that we didn’t already have any tools for that. Recentl…

This helped me a lot as I have learnt how to write a graph which allows you to print multiple sheets (different sheet sizes as well) and rename them within the one graph.

---

<div class="post-metadata">

**Author:** ![4bimfercesp](https://avatars.discourse-cdn.com/v4/letter/4/b782af/32.png) [@4bimfercesp](https://forum.dynamobim.com/u/4bimfercesp)\
**Post date:** [May 25, 2017, 2:49pm UTC](https://forum.dynamobim.com/t/help-with-renaming-multiple-pdf-files-first-dynamo-graph/12028/3 "2017-05-25T14:49:05Z")

</div>

@DeanB72  
You can also look at this as an alternative

> [@Customized PDF creation using Ghostscript, Dynamo and Python](https://forum.dynamobim.com/t/customized-pdf-creation-using-ghostscript-dynamo-and-python/11736):
>
> Hi All, This will be a “work in progress topic” as I need to explain Fully how to achieve this. First the basics: Revit 2016, Dynamo 1.3, Dyno Browser 0.6.1, Ghostscript 9.21, Redmon 1.9 and Python Ghostscript can be downloaded here [https://www.ghostscript.com/download/](https://www.ghostscript.com/download/) Redmon can be downloaded here [http://pages.cs.wisc.edu/~ghost/redmon/](http://pages.cs.wisc.edu/~ghost/redmon/) There are tons of write-up about Ghostscript online so feel free to read about it so you have an idea on how it works. Graph Image Below is a …

It has built-in renaming, auto sheet detection and auto-save to a given location.

thanks.

---

<div class="post-metadata">

**Author:** ![DeanB72](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@DeanB72](https://forum.dynamobim.com/u/DeanB72)\
**Post date:** [May 25, 2017, 6:38pm UTC](https://forum.dynamobim.com/t/help-with-renaming-multiple-pdf-files-first-dynamo-graph/12028/4 "2017-05-25T18:38:37Z")

</div>

Hi… Thanks for the replies. I have read Konrad’s articles and used them to get this far. My main problem now is figuring out how to get dynamo to rename all of the pdfs I create in a folder (however many that may be) without me needing to have a section of the graph for each one. ie… Is there a specific node I should be looking into that effectively specifies that a command is applicable to “all” the files that match a set criteria?  
Apologies if it’s in the articles mentioned but I haven’t seen it and when coding is shown, it goes completely over my head.

Thanks

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [May 26, 2017, 2:49am UTC](https://forum.dynamobim.com/t/help-with-renaming-multiple-pdf-files-first-dynamo-graph/12028/6 "2017-05-26T02:49:52Z")

</div>

@Konrad_K_Sobon’s node is set up to take a list of identifiers and rename **any** files which contain the matching identifier, no need to have multiple instances of this node as a result unless you want to run it on multiple directories. Just build coordinated lists of matching length and go to town. Try this:

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/0/903a9774930fbfa978f8a0b123b91c68269de0db.PNG)

Note that I had previously modified the Rename Files node to remove the loading of Revit specific libraries, transaction handling and document stuff which weren’t used and throw an error if you’re running it in studio.

---

<div class="post-metadata">

**Author:** ![DeanB72](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@DeanB72](https://forum.dynamobim.com/u/DeanB72)\
**Post date:** [May 26, 2017, 11:24am UTC](https://forum.dynamobim.com/t/help-with-renaming-multiple-pdf-files-first-dynamo-graph/12028/7 "2017-05-26T11:24:30Z")

</div>

Thanks for that Jacob… I’ll look over this in detail as soon as I get chance.

---

<div class="post-metadata">

**Author:** ![DeanB72](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@DeanB72](https://forum.dynamobim.com/u/DeanB72)\
**Post date:** [May 26, 2017, 2:38pm UTC](https://forum.dynamobim.com/t/help-with-renaming-multiple-pdf-files-first-dynamo-graph/12028/8 "2017-05-26T14:38:38Z")

</div>

Hi Jacob… I got error messages as follows when I tried it. From looking online I found a post that suggested each \ should be replaced with \ but it still didn’t work.

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/e/0e0a9787cedd1342b5e5352f336d0315962c65ca.PNG)

---

<div class="post-metadata">

**Author:** ![Joseph\_Peel](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@Joseph\_Peel](https://forum.dynamobim.com/u/Joseph_Peel)\
**Post date:** [May 26, 2017, 2:43pm UTC](https://forum.dynamobim.com/t/help-with-renaming-multiple-pdf-files-first-dynamo-graph/12028/9 "2017-05-26T14:43:47Z")

</div>

This is one situation where it is better to use a String node than just a code block with “”.  
String nodes have no problem with \ and other characters

---

<div class="post-metadata">

**Author:** ![DeanB72](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@DeanB72](https://forum.dynamobim.com/u/DeanB72)\
**Post date:** [May 26, 2017, 3:05pm UTC](https://forum.dynamobim.com/t/help-with-renaming-multiple-pdf-files-first-dynamo-graph/12028/10 "2017-05-26T15:05:30Z")

</div>

Thanks Joseph… That worked for the code block problem but now I get Traceback/WindowsErrors which I believe has got something to do with the Rename Files Node.

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/d/dd3ededa796d63f4f11356e6e27c0dfffca35aae.PNG)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [May 26, 2017, 3:13pm UTC](https://forum.dynamobim.com/t/help-with-renaming-multiple-pdf-files-first-dynamo-graph/12028/11 "2017-05-26T15:13:31Z")

</div>

It looks like you’re feeding a “path”+“Name” when all revit wants is the “Name” for the **New Names** input. The string replace needs the empty string input to remove the path.

---

<div class="post-metadata">

**Author:** ![DeanB72](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@DeanB72](https://forum.dynamobim.com/u/DeanB72)\
**Post date:** [May 26, 2017, 3:22pm UTC](https://forum.dynamobim.com/t/help-with-renaming-multiple-pdf-files-first-dynamo-graph/12028/12 "2017-05-26T15:22:51Z")

</div>

I believe I have done that ??

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/9/99babc60e57bb9221c900767451b0768c4898888.PNG)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [May 26, 2017, 3:35pm UTC](https://forum.dynamobim.com/t/help-with-renaming-multiple-pdf-files-first-dynamo-graph/12028/13 "2017-05-26T15:35:24Z")

</div>

Wire a watch node onto the “String.Replace” to see the results. It should just be “Current File Name.PDF” or something is amiss prior to the renaming.

---

<div class="post-metadata">

**Author:** ![DeanB72](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@DeanB72](https://forum.dynamobim.com/u/DeanB72)\
**Post date:** [May 26, 2017, 3:37pm UTC](https://forum.dynamobim.com/t/help-with-renaming-multiple-pdf-files-first-dynamo-graph/12028/14 "2017-05-26T15:37:47Z")

</div>

I already have got a watch node I think, unless I’m misunderstanding even more than I thought ? It seems to come out the same as it went in.

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/5/b5aacf0da73913cd5d7eae6a92086a4325e03363.PNG)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [May 26, 2017, 3:51pm UTC](https://forum.dynamobim.com/t/help-with-renaming-multiple-pdf-files-first-dynamo-graph/12028/15 "2017-05-26T15:51:38Z")

</div>

The String.Replace node not the String.Insert node. I believe you need to set the lower string node which currently has “”; with “” and remove the quotes form the start and end of the upper string node. Quotes in a code block is telling dynamo that this bit of content in the code block is a string. If you call a string node there is no need for the quotes.

---

<div class="post-metadata">

**Author:** ![DeanB72](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@DeanB72](https://forum.dynamobim.com/u/DeanB72)\
**Post date:** [May 26, 2017, 4:06pm UTC](https://forum.dynamobim.com/t/help-with-renaming-multiple-pdf-files-first-dynamo-graph/12028/16 "2017-05-26T16:06:55Z")

</div>

I think that’s solved it Jacob…

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/5/2536a7e26094067f234245d73e9aa3b4f1e94405.PNG)

but also involved changing the Rename Files node…

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/2/02eeeff2180dd45ef785e1072efe25188c097921.PNG)

I will test it further and tidy it all up but that’s given me a great start in Dynamo.

Thanks everyone’s peristence.

---

<div class="post-metadata">

**Author:** ![4bimfercesp](https://avatars.discourse-cdn.com/v4/letter/4/b782af/32.png) [@4bimfercesp](https://forum.dynamobim.com/u/4bimfercesp)\
**Post date:** [May 26, 2017, 4:20pm UTC](https://forum.dynamobim.com/t/help-with-renaming-multiple-pdf-files-first-dynamo-graph/12028/17 "2017-05-26T16:20:58Z")

</div>

@DeanB72

I know you have your solution already, well done.

In addition if you just need to rename. You can also use the old fashion “RENAME” graph below will create a CMD in your desired folder and you can run it separately outside by double clicking the Rename.cmd

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/c/4c7741dc11faaf37480b234cc53b9063bf9751ff.png)

do not worry about the “null” on the write to CSV node it will create the cmd.

here is the graph if you want to use it.

[rename\_files.dyn](https://forum.dynamobim.com/uploads/short-url/aHCbkyMZ42Ub0hdHEhmvSuKoNTh.dyn) (10.3 KB)

thanks…

---

<div class="post-metadata">

**Author:** ![DeanB72](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@DeanB72](https://forum.dynamobim.com/u/DeanB72)\
**Post date:** [May 27, 2017, 2:46pm UTC](https://forum.dynamobim.com/t/help-with-renaming-multiple-pdf-files-first-dynamo-graph/12028/18 "2017-05-27T14:46:25Z")

</div>

Thanks for this. I haven’t had chance to look into it yet but are you saying a file can be created using dynamo but that can then be run independently/separate to dynamo?

---

<div class="post-metadata">

**Author:** ![4bimfercesp](https://avatars.discourse-cdn.com/v4/letter/4/b782af/32.png) [@4bimfercesp](https://forum.dynamobim.com/u/4bimfercesp)\
**Post date:** [May 27, 2017, 3:35pm UTC](https://forum.dynamobim.com/t/help-with-renaming-multiple-pdf-files-first-dynamo-graph/12028/19 "2017-05-27T15:35:29Z")

</div>

Yes it will create a file located on your specified location. Just try it…it will create a file called rename.cmd that you can run separately outside revit and dynamo. Its just a batch file a very old trick but really works and simple.

---

<div class="post-metadata">

**Author:** ![DeanB72](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@DeanB72](https://forum.dynamobim.com/u/DeanB72)\
**Post date:** [May 27, 2017, 3:53pm UTC](https://forum.dynamobim.com/t/help-with-renaming-multiple-pdf-files-first-dynamo-graph/12028/20 "2017-05-27T15:53:00Z")

</div>

I’ll give that a try as soon as I get chance. Do you know if there is list of other “. cmd” files readily available or easily creatable. I’m not sure what I would want them to do but the concept intrigues me as I had no idea things like that were possible without having advanced coding skills (which I obviously haven’t).  
Thanks for the tip off

---

<div class="post-metadata">

**Author:** ![4bimfercesp](https://avatars.discourse-cdn.com/v4/letter/4/b782af/32.png) [@4bimfercesp](https://forum.dynamobim.com/u/4bimfercesp)\
**Post date:** [May 27, 2017, 4:19pm UTC](https://forum.dynamobim.com/t/help-with-renaming-multiple-pdf-files-first-dynamo-graph/12028/21 "2017-05-27T16:19:37Z")

</div>

I am not sure what else…depending on your requirement. Dynamo is not built for this purpose but its good it can do this trick on writing ‘cmd’. Try it first and see if it will do the trick as an alternative to the above solution.

[Next page](https://forum.dynamobim.com/t/help-with-renaming-multiple-pdf-files-first-dynamo-graph/12028.md?page=2)
