Can anyone help me with my script please? See attached.
I am trying to move (or archive) older drawing revisions from one folder to another. The first revision of a drawing would be P01 then the next revision would be P02, P03, etc…
So if my drawing revision was at P03 I want to move the P02 & P01 versions of that drawing to another folder.
Our typical drawing file name consist of the following:
0971-XXX-00-XX-GF-DR-S-1000-P01
My script brakes down the drawing file name to keep the last 2 items which are the drawing Number and Revision as shown below:
1000-P01
Now I am stuck and I don’t know how to get my script to filter out the older drawing revisions and move those files to another folder.
Can anyone help me with this and advise if there is an easier way to do this please?
the key is how to filter, first sort them by name to get the last revision at last, then use GroupByKey node, and the 1000-p01 values as a keys, now you will have each revision in group, use LastItem node to get the last revision, the other revisions flatten them and it will be in one list , and manage to save each group to a place
@Kieran_Atherton, I would do it slightly differently which i have uploaded a copy onto my github or attached below.
I would grab the file name then remove the revision, then group what is left. Once things are grouped you would grab the last item in each group and split the original paths by this list to get only the ones that need to be moved.
Brendan, I’ve tested your script, however, it doesn’t seem to move the older revision files to my selected archive folder but it doesn’t give me any error warnings? Not sure what I am doing wrong
Morning Brendan, I changed the separator but your move files phython node flags up a warning:
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 14, in
File “C:\Program Files\Autodesk\Revit 2020\AddIns\DynamoForRevit\IronPython.StdLib.2.7.8\shutil.py”, line 316, in move
File “C:\Program Files\Autodesk\Revit 2020\AddIns\DynamoForRevit\IronPython.StdLib.2.7.8\shutil.py”, line 144, in copy2
File “C:\Program Files\Autodesk\Revit 2020\AddIns\DynamoForRevit\IronPython.StdLib.2.7.8\shutil.py”, line 97, in copyfile
@Kieran_Atherton, I think this might be to do with how dynamo now loads python modules since Dynamo 2.1. This is because you do not have to append the iron python module folder from this version on wards.
Eg line 7 in this example:
Try this version which i have removed all of the ironpyton lib folder appends from any python nodes.
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 13, in
File “C:\Program Files\Autodesk\Revit 2020\AddIns\DynamoForRevit\IronPython.StdLib.2.7.8\shutil.py”, line 316, in move
File “C:\Program Files\Autodesk\Revit 2020\AddIns\DynamoForRevit\IronPython.StdLib.2.7.8\shutil.py”, line 144, in copy2
File “C:\Program Files\Autodesk\Revit 2020\AddIns\DynamoForRevit\IronPython.StdLib.2.7.8\shutil.py”, line 97, in copyfile
IOError: [Errno 2] Could not find a part of the path ‘C:\Dynamo Shared\Archive\0931-SWA-00-B2-DR-S-1001-P01.pdf’.: C:\Dynamo Shared\Archive\0931-SWA-00-B2-DR-S-1001-P01.pdf
@Kieran_Atherton No worries, i did assumed it would make the folder if it did not exist.
Therefore i have just updated the last python node to include a way to create the folder if it does not exist.
Hopefully you agree this is a better way to do what you was after than the original way, sorry it is python heavy but i find some things easier in python. Do ask if you want to understand certain parts.
Thanks Brendan, I understand what each of your nodes are doing but the problem I have is knowing how to put them all together to make a script run correctly. But, i suppose that boils down to experience.
Do you have any tutorial or training recomendations ?