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

Discuss and share scripts and script files...
Post Reply
kelwin
Posts: 8
Joined: 08 Feb 2012 00:05

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

Post 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.
Attachments
find duplicate files (older revision).PNG
find duplicate files (older revision).PNG (46.71 KiB) Viewed 731 times

LittleBiG
Posts: 1846
Joined: 08 Apr 2011 12:57
Location: Win10x64

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

Post 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.

Post Reply