I realized I should post this new question in a new thread. When I output CNC program files (txt files) with my CAD/CAM program, a script in the CAM database triggers a batch file which creates user named folders in a fixed local directory (C:\CncOut), and then puts the CNC program files into those folders and XCopies them to a mapped drive on the network.
Several of you have helped me with this so far, so I thank you very much. It's solved several problems and saved a good bit of time already.
I would like to delete previously output files left in this local directory though. The deletion would target old files of an earlier run number.
Let's suppose yesterday I stopped the batch file before it completed it's task of creating the folders, and it left these files in the CncOut directory.
R77001001.txt
R77001002.txt
R77001003.txt
R77002001.txt
R77002002.txt
R77003001.txt
77 is the run number, and the other numbers can be ignored for the time being. For example's sake, lets say I found a mistake in the program code and I re-output these files today. Subsequently the run numbers of the new output files would advance to the next number, looking like this:
R78001001.txt
R78001002.txt
R78001003.txt
R78002001.txt
R78002002.txt
R78003001.txt
So now I have yesterday's output and todays output in the CncOut directory, and currently if the older files are left on the local directory like this, my batch file will just add all of them to the new folder, and xcopy them to the mapped drive on the network.
I would like to delete the old folder (if it was created before the batch file was stopped), and the old files by comparing run numbers.
Is there a way to target just the old files by name?