Hello again Creo+PowerShell Followers!
Are you one of those Creo people or know one who leaves their files all over the place? Do you find it impossible and frustrating when trying to locate a file to work on? I may have the solution for you!
Today, I am going to show you a fairly simple script that will locate the latest copy of each uniquely named Creo file and copy it to a user-defined folder. Take this as a chance to start over by having all of your files in the same location. You can also use this script to see what folders contain Creo files if you want to make sure you have added all relevant search paths to your config.pro.
I want to start by saying that this script is simple PowerShell trickery and has nothing to do with the Creo API but it was made specifically for the purpose of working with Creo files in the ways I have stated above. You can repurpose this script to work with other file types as well.
High Level Overview:
Here is a list of the major steps in the script.
Finding All Folders with Creo Files (findCreoFilePaths Function):
The script will automatically detect all drives and mapped drives on your computer. You can and need to manually add any network locations to the $networkLocations array in order to include those directories. Starting from these paths, the script will recursively search all folders and subfolders for Creo files. I have only included .prt, .asm, and .drw but you can include additional file extensions.
A csv named "CreoFileLocations.csv" will be created showing all unique locations where such files were found. Because this step is the most time consuming, I have include a way to include an existing "CreoFileLocations.csv" from a previous run to speed up additional runs. Make sure to set $useExistingCreoFileLocationsCSV = $true in order to use this feature.
Finding All Latest Creo Files (findLatestCreoFiles Function):
Now that we have all the paths where Creo files exist, it makes the rest of the script much faster. We will no longer recursively search these paths as we already have the exact path of Creo files. For each path found, the script will:
Copying All Latest Creo Files to Specified Folder Location (copyLatestCreoFiles Function):
Now that we have a list of the latest Creo files, we can easily iterate through it and copy each file to a single location. Once the copy is complete, a CSV named "CreoFileCopyResults.csv" will display the copy status of each file confirming whether or not the copies were successful. You would just need to add this single folder to your Creo search path going forward if you do indeed have all the files you need.
Although the script doesn't have full error checking, there is some basic logging to help you identify points where issues occur. Below is an example of a successful run of the script.
Important Things to Note:
PLM engineer while "on the clock", programmer, designer, dreamer all other times.