#1 2008-04-25 20:10

ynotrobits
Member
Registered: 2008-04-25
Posts: 3

Newbie: Create rule that only applies to a specific subfolder

I have a group of files held within subfolders of a main folder named CAD

Each folder name is a single letter from A through L

Example: C:\CAD\A

Example: C:\CAD\B

Each of the above subfolders contain 16 files that all have the letters 'ZZ" as part of their file names



I would like to create a rule that only apply to specific subfolders.

So for instance, using the example above, I would like to have a rule that replaces ZZ with  Z1 for those files that are in subfolder A

I would then like to create another rule that replaces ZZ with Z2 for those files that are in subfolder B

I would then like to create another rule that replaces ZZ with Z3 for those files that are in subfolder C

And so on....

I haven't quite been able to figure out how to create a filter that targets files based on file location.

Any help would be greatly appreciated; this is my last hurdle to creating a cool macro that re-writes library parts for my cad program.

Thanks!

---A.J

Offline

#2 2008-04-25 20:36

krtek
Senior Member
From: Łódź (Poland)
Registered: 2008-02-21
Posts: 262

Re: Newbie: Create rule that only applies to a specific subfolder

Hi,
I'm quite surprised, but you can't apply filters/masks to path (only to filename) when marking/selecting. (Am I right Dennis or I simply can't find the option?).
Even RegEx rule doesn't operate on filename with path and only on pure filename. So it won't help.
Using mask to filter files added to ReNamer (which is possible with Filters/Masks) won't help here -> the same you achieve when you simply put subfolder into renamer - rename files - remove files from ReNamer - put next subfolder and so on.
But that's not the very best solution.

The thing that will help you is PascalScript. Unfortunately I'm not a pro in it and I can't write it for you. But maybe someone can.

Give us a bit more information. First of all give few real examples of the filenames (are they of constant-length, where the ZZ part is in filename?). Best of all give few examples of filenames with path paired with new (the ones you want to change for) filenames with path.
And stay tuned.

Last edited by krtek (2008-04-25 20:39)


Regular Expressions are not as hard to understand as you may think. Check ReNamer's manual or nice Regular Expressions tutorial for more info and start to use full power of applications that use them (like ReNamer, Mp3Tag and so on).

Offline

#3 2008-04-25 21:14

ynotrobits
Member
Registered: 2008-04-25
Posts: 3

Re: Newbie: Create rule that only applies to a specific subfolder

Thank you for replying.

All my file names are consistent. The only difference is the subfolder name.

Here is  the file set for C:\CAD\A

ZZ.000.DXF
ZZ.063.DXF
ZZ.125.DXF
ZZ.188.DXF
ZZ.250.DXF
ZZ.313.DXF
ZZ.375.DXF
ZZ.438.DXF
ZZ.500.DXF
ZZ.563.DXF
ZZ.625.DXF
ZZ.688.DXF
ZZ.750.DXF
ZZ.813.DXF
ZZ.875.DXF
ZZ.928.DXF

The file set for C:\CAD\B is identical:

ZZ.000.DXF
ZZ.063.DXF
ZZ.125.DXF
ZZ.188.DXF
ZZ.250.DXF
ZZ.313.DXF
ZZ.375.DXF
ZZ.438.DXF
ZZ.500.DXF
ZZ.563.DXF
ZZ.625.DXF
ZZ.688.DXF
ZZ.750.DXF
ZZ.813.DXF
ZZ.875.DXF
ZZ.928.DXF

What I need to rename is just the "ZZ" portion of the filename:

In subfolder "A" I would rename "ZZ" to "Z1"

From----------------------To

ZZ.000.DXF--------------Z1.000.DXF
ZZ.063.DXF--------------Z1.063.DXF
ZZ.125.DXF--------------Z1.125.DXF
ZZ.188.DXF--------------Z1.188.DXF
ZZ.250.DXF--------------Z1.250.DXF
ZZ.313.DXF--------------Z1.313.DXF
ZZ.375.DXF--------------Z1.375.DXF
ZZ.438.DXF--------------Z1.438.DXF
ZZ.500.DXF--------------Z1.500.DXF
ZZ.563.DXF--------------Z1.563.DXF
ZZ.625.DXF--------------Z1.625.DXF
ZZ.688.DXF--------------Z1.688.DXF
ZZ.750.DXF--------------Z1.750.DXF
ZZ.813.DXF--------------Z1.813.DXF
ZZ.875.DXF--------------Z1.875.DXF
ZZ.928.DXF--------------Z1.928.DXF


In subfolder "B" I would rename "ZZ" to "Z2"

From----------------------To

ZZ.000.DXF--------------Z2.000.DXF
ZZ.063.DXF--------------Z2.063.DXF
ZZ.125.DXF--------------Z2.125.DXF
ZZ.188.DXF--------------Z2.188.DXF
ZZ.250.DXF--------------Z2.250.DXF
ZZ.313.DXF--------------Z2.313.DXF
ZZ.375.DXF--------------Z2.375.DXF
ZZ.438.DXF--------------Z2.438.DXF
ZZ.500.DXF--------------Z2.500.DXF
ZZ.563.DXF--------------Z2.563.DXF
ZZ.625.DXF--------------Z2.625.DXF
ZZ.688.DXF--------------Z2.688.DXF
ZZ.750.DXF--------------Z2.750.DXF
ZZ.813.DXF--------------Z2.813.DXF
ZZ.875.DXF--------------Z2.875.DXF
ZZ.928.DXF--------------Z2.928.DXF


Right now, the way that I'm doing this is that I'm renaming each group of files by loading in a single subfolder Ex: C:\CAD\A and then using a rule to rename "ZZ" to "Z1"

After that's completed, I load up C:\CAD\B and then use a rule to rename "ZZ" to "Z2"

And so on...

This is working but it would speed me up to be able to do all my subfolders (A-L) in one shot as opposed to individually.

I don't know if this will make things clearer but the concept behind this is that:

Each subfolder represents an inch. 
Each file represents 1/16th of an inch
The main folder (C:\CAD) represents a foot.


Thus the reason for the 12 subfolders:

Subfolder "A" represents inch #1

Subfolder "B"  represents inch #2

And so on for a total of 12 individual subfolders (12 x 1 inch = foot)

Thanks again

Last edited by ynotrobits (2008-04-25 21:41)

Offline

#4 2008-04-25 22:08

krtek
Senior Member
From: Łódź (Poland)
Registered: 2008-02-21
Posts: 262

Re: Newbie: Create rule that only applies to a specific subfolder

As its only 12 operations, I think it will be the quickest way for you to do it as you do (manually loading each subfolder).
Maybe someone will solve the problem "globally" by writing the script, but I think its not worth effort, as writing the script will take more time, then renaming subfolder by subfolder...
Use Drag&Drop and Ctrl+del to clear the file list (although clearing filelist is not necessary cause after renaming you won't have more ZZ files in "previous" folders).

That will help you now. Writing the script would be reasonable if you needed to do such operations more often.
Cheers.


Regular Expressions are not as hard to understand as you may think. Check ReNamer's manual or nice Regular Expressions tutorial for more info and start to use full power of applications that use them (like ReNamer, Mp3Tag and so on).

Offline

#5 2008-04-25 22:41

ynotrobits
Member
Registered: 2008-04-25
Posts: 3

Re: Newbie: Create rule that only applies to a specific subfolder

I should have been more clear: This in an ongoing project.

Every day, I will have  new polygons to add to the list. These number in the hundreds.

The way this works is that a CAD macro takes an existing polygon and resizes it a 16th of an inch at a time.

After it resizes the polygon by an 1/16 of an inch, the macro writes the polygon to a file with the inch increment, i.e. ZZ.063


After the macro completes itself, I use a search and replace text function to change the "ZZ" portion of the name to the correct terms to describe the polygons.

The "ZZ" represents the inch size of the polygon

Ex: ZZ.063 becomes 25.063

These are then stored in a library.


When the next polygon is loaded into the macro, the process repeats itself and the "ZZ" files are overwritten.

I then have to repeat the search and replace tasks to store the new polygon.



The reason I want to rename to "Z1" "Z2" "Z3" etc, is that there are also associated text files that are linked to these DXF files.

The text files are set up to process with "Z1" "Z2" "Z3" depending on the inch increment. These are generated using a different program.

Unfortunately, I'm stuck with only "ZZ" within the CAD macro. The CAD macro was not set up to toggle upward with Z1, Z2 etc. It always uses "ZZ"


Thank you for all your attention on this.

Last edited by ynotrobits (2008-04-25 23:47)

Offline

#6 2008-04-26 02:13

krtek
Senior Member
From: Łódź (Poland)
Registered: 2008-02-21
Posts: 262

Re: Newbie: Create rule that only applies to a specific subfolder

Ok! big_smile
I've done a small research. And decided that I am able to write such a script. Here you go:

var
  Folders: TStringsArray;
  Folder, Z: WideString;
begin
  Folders := WideSplitString(WideExtractFileDir(FilePath), '\');
  Folder := Folders[Length(Folders)-1];
  case Folder of
    'A': Z := 'Z1';
    'B': Z := 'Z2';
    'C': Z := 'Z3';
    'D': Z := 'Z4';
    'E': Z := 'Z5';
    'F': Z := 'Z6';
    'G': Z := 'Z7';
    'H': Z := 'Z8';
    'I': Z := 'Z9';
    'J': Z := 'Z10';
    'K': Z := 'Z11';
    'L': Z := 'Z12';
  else Z:='ZZ';
  end;
  
  FileName:=WideReplaceStr(FileName, 'ZZ', Z);
  
end.

Looks simple, doesn't it?
Use as a PascalScript Rule.
And tell me how it works!


BTW, if you would like to do it totally as a macro, you can start your renaming script from command line.
First - download the LATEST (22.04) beta version of ReNamer. Then Add PascalScript Rule. Next change Filters settings (you need only two ticks - in "Add files within folders" and "Include Subfolders"). Make sure you have no Masks set in your filter settings.
And then "Preset\Save as" (eg. ZZ) and TICK the new option "Save filter settings with preset".
If you named your preset as "ZZ" running Renamer from command line will look like this:
ReNamer /rename "ZZ" "C:\CAD"
Voila!

Last edited by krtek (2008-04-26 02:48)


Regular Expressions are not as hard to understand as you may think. Check ReNamer's manual or nice Regular Expressions tutorial for more info and start to use full power of applications that use them (like ReNamer, Mp3Tag and so on).

Offline

Board footer

Powered by FluxBB