making folder from CNC program names?

English support forum

Moderators: Hacker, petermad, Stefan2, white

dragonworks
Junior Member
Junior Member
Posts: 29
Joined: 2015-10-20, 20:00 UTC
Location: poughkeepsie ny

Post by *dragonworks »

So far, with your help, I have accomplished the most important aspect of this project, but I need to continue on and have met another stumbling block I need help with. I hope I am being clear with what I am about to ask, but not knowing how to do it may also mean I am not sure how to ask the question. I thank you for your patience.

I have a path as follows F:\CNC Programs\JD\121\
In the \121\ folder I have many other folders with individual part numbers
such as 121-00-00-9014 i.e. the path would be F:\CNC Programs\JD\121\121-00-00-9014:
Inside th121-00-00-9014 folder I have five folders, MCX, POST, SOLIDS,PDF AND SETUPSHEETS.

I have another path F:\CNC Programs\Mill\MCX-files\121
Inside this last folder I have all my mastercam files beginning with 121 such as
121-00-00-9014 R00.MCX.

What I would like to do is take all the .MCX files from the F:\CNC Programs\Mill\MCX-files\121, file
and using the first fourteen characters of the individual MCX files, copy them into the corresponding
F:\CNC Programs\JD\121\*.*\MCX folders. So, using the above example

The file 121-00-00-9014 R00.MCX would get copied into the F:\CNC Programs\JD\121\121-00-00-9014\MCX folder.
A file 121-25-35-001 R01.MCX would get copied into the F:\CNC Programs\JD\121\121-25-35-0001\MCX folder, and so forth



I can only do this one at a time now and need to find a quicker way.
Once again I have thousands of file to do this to.
I would like to make shortcuts for other files with different extensions and put them in folders using the same method.?
Any Help would be greatly welcome
Thank You
Jerry Dragon
User avatar
ZoSTeR
Power Member
Power Member
Posts: 1052
Joined: 2004-07-29, 11:00 UTC

Post by *ZoSTeR »

You could move them with this MRT mask:

Code: Select all

..\..\..\JD\121\[N1-14]\MCX\[N]
For stuff like this a little script is often more flexible.
For example in PowerShell:

Code: Select all

$sourcePath      = "f:\CNC Programs\Mill\MCX-files\121\"
$destinationPath = "f:\CNC Programs\JD\121\"

$sourceFiles = Get-ChildItem -Path $sourcePath

foreach ($file in $sourceFiles)
{
    $first14Chars = $file.Name.Substring(0,14)
    $finalDestination = $destinationPath + $first14Chars + "\MCX\"
    Copy-Item -Path $file.FullName -Destination $finalDestination
}
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

dragonworks,
Again, you can move them all using branch view (Ctrl+B, then Num+, *.mcx) or search results window (Find files, *.mcx, Feed to listbox, select all) together with MRT, e.g. as ZoSTeR suggested, but this will move files, not copy.
Or you can select these files and copy them first (e.g. my CopyTree plugin allows copying from multiple folders with directory structure) and then move copies with MRT.

BTW you can also get 121 as [N1-3], just in case if you have another folders like 121 waiting for processing.
dragonworks
Junior Member
Junior Member
Posts: 29
Joined: 2015-10-20, 20:00 UTC
Location: poughkeepsie ny

Post by *dragonworks »

Going to get the IT guy in on this again and go through this. I need to keep him abreast of what I am doing in case I run into trouble. We have an outside source backing us up and can retrieve just about anything as long as I know I lost it.
MVV, I used [N1-5] to move my Mpart and Kpart programs which have 5 initial characters instead of 14, worked well.
I have forgotten almost all the dos commands I ever knew and have downloaded dos instructions to browse over again. Only so many hours in the day. Most of the time I am programming for or setting up CNC machines. This is a project I took upon myself to help streamline the file management of this department.
Thanx all again.
Jerry
dragonworks
Junior Member
Junior Member
Posts: 29
Joined: 2015-10-20, 20:00 UTC
Location: poughkeepsie ny

Post by *dragonworks »

ZoSTeR wrote:You could move them with this MRT mask:

Code: Select all

..\..\..\JD\121\[N1-14]\MCX\[N]
For stuff like this a little script is often more flexible.
For example in PowerShell:

Code: Select all

$sourcePath      = "f:\CNC Programs\Mill\MCX-files\121"
$destinationPath = "f:\CNC Programs\JD\121"

$sourceFiles = Get-ChildItem -Path $sourcePath

foreach ($file in $sourceFiles)
{
    $first14Chars = $file.Name.Substring(0,14)
    $finalDestination = $destinationPath + $first14Chars + "\MCX"
    Copy-Item -Path $file.FullName -Destination $finalDestination
}
this looks like it might work also, I can follow it to an extent, not sure if this is exactly what to type in, for instance,=Get-ChildItem- etc. is this a command or an example?
And, power shell, is that the black box for dos commands?
User avatar
ZoSTeR
Power Member
Power Member
Posts: 1052
Joined: 2004-07-29, 11:00 UTC

Post by *ZoSTeR »

PowerShell is basically the successor to the "black DOS box".

Hopefully your IT guy can set it up for you and show you the basics of the PowerShell ISE (Integrated Scripting Environment).
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I would prefer PowerGUI if we talk about PowerShell GUI environment.

But if we just want to run PowerShell script from command line, the script should be saved as .PS1 file and run using this command line:

Code: Select all

powershell.exe -NoProfile -ExecutionPolicy Bypass -File "script.ps1"
This may be done from console window or just from TC buttonbar button (start path field must be empty for that button in order to start script from currently opened dir).
dragonworks
Junior Member
Junior Member
Posts: 29
Joined: 2015-10-20, 20:00 UTC
Location: poughkeepsie ny

Post by *dragonworks »

[quote="ZoSTeR"]You could move them with this MRT mask:

Code: Select all

..\..\..\JD\121\[N1-14]\MCX\[N]
Well, either I did that wrong, or it didn't work. I forgot to copy the files to the desktop and I deleted them without thinking, oh well, you win some you lose some. If we make those parts again I will have to program them over again!
When you delete something using TC where does it go? I expected to find the folder and files in the recycle bin, but NOOOOO.
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Well, either I did that wrong, or it didn't work.
You should check paths and names that TC shows in resulting column, every ".." means move one level up so it is not hard to evaluate target folder...
When you delete something using TC where does it go?
By default TC deletes to Recycle bin, but it may be changed in Copy/Delete settings.
dragonworks
Junior Member
Junior Member
Posts: 29
Joined: 2015-10-20, 20:00 UTC
Location: poughkeepsie ny

Post by *dragonworks »

as far as I know I never changed any settings in TC.
It's not a job, it's an adventure.
Post Reply