Page 1 of 1

Help with a script to find file (trim file name)

Posted: 04 Aug 2022 04:01
by kelwin
I would appreciate assistance with a script to find drawings with similar names - but with different drawing revisions (see pic)

The scenario is:
* builders issuing updated drawings,
* and need to move the superseded drawings to the superseded folder and only have the current revision drawing in the main folder.

In the current project I'm working on for room details there are over 4500 drawings in the series, and over a 1000 new drawings have been updated.



Goal is to be able to find/select all the files via a script, and then I can either delete, cutnpaste elsewhere etc.

Note:
- Because drawing names and method of identifying revisions change per project (eg some are (c) or [1] ) the best option would be able to define how many characters to ignore at the end of the file name.
- Also just want to limit the script to the current selected folder (ignore any subfolders)


I tried searching for a solution already posted, so if I missed, please advise the link to the script.

Re: Help with a script to find file (trim file name)

Posted: 07 Sep 2022 18:15
by LittleBiG
The script assumes that the filenames don't contain brackets other than the last one around the version.

Code: Select all

//select previous versions
 $list = formatlist(get("ItemsNames"),"n",<crlf>); //natural sort order
 $oldversions = "";
 $i = 1;
 while ($i < gettoken($list,"count",<crlf>)) {
  $item = gettoken($list,$i,<crlf>);
  $itembase = regexreplace($item,"[\(\[].*$");
  $nextbase = regexreplace(gettoken($list,$i+1,<crlf>),"[\(\[].*$");
  if ($itembase == $nextbase) {
   $oldversions .= $item . <crlf>; //there is a newer one so this is obsolete
  }
  $i++;
 }
 selectitems $oldversions;
I have recently created a similar script to find those compressed files which have been extracted to folders with the same name (for deleting the already extracted zip files). This was quite similar task.