Help with renaming multiple pdf files - First Dynamo graph


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.



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.



I believe I have done that ??



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.



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.



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.



I think that’s solved it Jacob…

but also involved changing the Rename Files node…

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

Thanks everyone’s peristence.




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

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 (10.3 KB)




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?



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.



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



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.



Hi… I tried the graph which did create the .cmd file but when I run it, I get an error saying… “the syntax of the command is incorrect”



Can you send the text in the rename.cmd…it should create a command like this…

rename “c:\yourpdffile.pdf” “new.pdf”

If its not like that review your graph maybe you missed something, see if the " " are written…the error is due to incorrect command syntax and normally this is due to missing quotes " ". it should work coz i tested it and use this code.

Also do not forget to delete your rename.cmd everytime you finished using it. Just to tidy up your files just incase you run it later by accident.



The text does seem to be like that. Not easy to be sure because when I run it, the error flashes up for a split second and tgen disappears so i have to repeatedly run it to try see the text of the error. I’m wondering if it could be related to the version of dynamo I’m using as I had to download an educational version on my home laptop to try it. Maybe it will work fine on my office computer because I did check my graph quite thoroughly and also downloaded yours. I’ll try on my office workstation and take it from there.

Thanks for your help



4bimfercesp… This is the error message I’m getting…



your nearly there…you just have "\ on your command it should just be quotes "…

post your graph and I will check.



Thanks… That’s what I was thinking but not sure where I get rid of it without causing another error.

I’m guessing it’s the code block containing the "rename "; that’s inserting it ? But if I change that I seem to get the code block turning red.



Found the problem node…

It was the C:\TEST that needed an extra \ on the end in order for it to be replaced. As a test I have input the directory path as a string and that works but I’m not sure if that’s the best workaround ?




try this…graph

rename_files.dyn (11.0 KB)

I added a code block to remove the …