GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Can Directory Opus do this (moving and renaming files)

scripting

#1

Hello i'm not very familiar with the scripting\regext side of Directory Opus so forgive me if this is a daft question.

We have the following folder structure.

Folder1\
fileid_stack_00_slice_0615.tif
fileid_stack_00_slice_0616.tif
fileid_stack_00_slice_0617.tif
fileid_stack_00_slice_0618.tif
Folder2\
fileid_stack_01_slice_0615.tif
fileid_stack_01_slice_0616.tif
fileid_stack_01_slice_0617.tif
fileid_stack_01_slice_0618.tif
Folder3\
fileid_stack_02_slice_0615.tif
fileid_stack_02_slice_0616.tif
fileid_stack_02_slice_0617.tif
fileid_stack_02_slice_0618.tif
Folder4\
fileid_stack_03_slice_0615.tif
fileid_stack_03_slice_0616.tif
fileid_stack_03_slice_0617.tif
fileid_stack_03_slice_0618.tif

What we want to do is take each image from a set out of each folder and put them in folder together and then append an incremental number to the end of it.

So it would end up looking like this.

folder_0615\
fileid_stack_00_slice_0615_1.tif
fileid_stack_01_slice_0615_2.tif
fileid_stack_02_slice_0615_3.tif
fileid_stack_03_slice_0615_4.tif

folder_0616\
fileid_stack_00_slice_0616_1.tif
fileid_stack_01_slice_0616_2.tif
fileid_stack_02_slice_0616_3.tif
fileid_stack_03_slice_0616_4.tif

folder_0617\
fileid_stack_00_slice_0617_1.tif
fileid_stack_01_slice_0617_2.tif
fileid_stack_02_slice_0617_3.tif
fileid_stack_03_slice_0617_4.tif

folder_0618\
fileid_stack_00_slice_0618_1.tif
fileid_stack_01_slice_0618_2.tif
fileid_stack_02_slice_0618_3.tif
fileid_stack_03_slice_0618_4.tif

In this example there is only 4 sets, 0615-1618 but in reality there will be many sets in each of the four folders

Is this something Directory Opus can help with?

Thanks


#2

This can be done by anybody who's familiar with scripting. DO is not really required for this, but can be of help triggering the processing. So an external script in perl, python, vbs, php or jscript will do just fine, wrapping this into a DO button is the ice on the cake. o)


#3

You can do most of this directly in DOpus.

Go into Flat View, No Folders.

Select the files you want renamed.

Select Type: Regular Expressions
Enter as the Old name: ((.*)(\d{4}).tif)
Enter as the New name: ..\Folder
\3\\1

Now you can leave flat view. You will have to manually remove the empty original folders. It doesn't handle adding the numeric sequencing.




#4

To get sequence numbers, based on your existing 0-based sequence numbers, use:

Old name: (._0(\d+).*(\d{4})).(.*)
New name: ..\Folder_\3\\1_\2.\4



#5

Thank you very much MrC.

I'm going to give this a go and see how I get on.

Cheers.


#6

Just tried it and it works great. Thanks MrC

Is there anyway I can put these two rename commands into two buttons to make it faster to run?

Edit: Just found the rename preset option. Is there anyway to "run" a rename preset via a button?
Edit2: Looks like Leo answered this question here - Assign Rename Preset to Toolbar


#7

Nice to see people know their weapons! o) Thanks MrC!
If DO internal things can be reused and combined, that's most likely the top nodge solution.


#8

Sorry to ask another question about this but how do I go about getting the numbering to start from 1 instead of 0? I'm sure it's a quick change but I can't figure out what it is.

I've been changing different parts of the code for the New name section but i'm not able to change the bit I need. I'm assuming it's the \2. part of the sequence but when I change the figure it just changes the information that's displayed rather than change the value of the number.

This is the existing code.

To get sequence numbers, based on your existing 0-based sequence numbers, use:

Old name: (.*_0*(\d+)_.*_(\d{4})).(.*)
New name: ..\Folder_\3\\\1_\2.\4

Thanks for any pointers.


#9

Hi reck,

I'm afraid it isn't a quick change. The regular expression can only capture existing data, not perform expression evaluation such as arithmetic. For this, you'll need a script.


#10

Hi MrC,

OK I see. I didn’t realise it was simply using the digits already in the filename. I’ll see if the software can output the files starting with 1 instead of 0.

Thanks for the reply


#11

If you want to use the Dynamic Renamer, it can do the full regular expression and arithmetic for you in one shot.