View previous topic :: View next topic |
Author |
Message |
martix
Joined: 20 Apr 2007 Posts: 17
|
Posted: Fri May 09, 2008 2:12 am Post subject: Get name from one file and put it on another |
|
|
How can I do that?
I want to take a string from one filetype and add it to the name of another one.
I basically want the search pattern to work on one type of file and the replace pattern on another. |
|
Back to top |
|
 |
admin Site Admin
Joined: 09 Mar 2007 Posts: 448 Location: Canada
|
Posted: Fri May 09, 2008 4:30 am Post subject: |
|
|
This might require a plugin.
I need more information.
Can you give some specific examples please.
Thanks,
Peter. |
|
Back to top |
|
 |
martix
Joined: 20 Apr 2007 Posts: 17
|
Posted: Fri May 09, 2008 3:01 pm Post subject: |
|
|
Not that an example will could make things a lot clearer, but why not.
The most useful thing would be take the name from a video file and apply it to its subtitle or vice versa...
Say "House MD 101 - Pilot.avi" and "House 1x01.srt"
Take name one and apply it to name two. |
|
Back to top |
|
 |
admin Site Admin
Joined: 09 Mar 2007 Posts: 448 Location: Canada
|
Posted: Fri May 09, 2008 4:26 pm Post subject: |
|
|
There is no general way to associate what are basically arbitrary name pairs. For the example, you could find the 2 files with the word House and 01 and map them to the same prefix but you would have to do that for every pair of names.
This is what I would do.
1)
Enable the 'general options' attribute for showing unchanged names.
2)
Run the scan on the main window. Just do something like search for 'a' and replace with 'a'. This will result in the preview window showing all the existing filenames. (in the upcoming version 2.19 you won't have to put anything in the custom list in order to get a preview of all currenlty existing names).
3)
Right click on the preview window and pick the option to 'copy full pathnames to the clipboard' .
Copy the clipboard data to a filename where you can manually edit to create pairs of filenames in preparation for importing the file back to PFrank.
OR
Use the export option to export the preview columns to a csv file (you can first disable the display of all the columns you don't want). Edit the csv file to create pairs of filenames
4)
Import the file to PFrank and rename.
This procedure should be much easier than using the mouse to rename the files in the explorer window.
I'll just mention that there is a grouping feature where if you already have filenames with the same prefix, you can insert metadata from one of the file types and insert that data into all the filenames which have the same prefix. e.g. if you have the filenames:
House 1x01.avi
House 1x01.srt
and the avi file has metadata with say the video width and height, then you could insert the info into both the avi and srt file resulting in something like:
House 1x01 (350x650).avi
House 1x01 (350x650).srt
Peter. |
|
Back to top |
|
 |
martix
Joined: 20 Apr 2007 Posts: 17
|
Posted: Fri May 09, 2008 9:38 pm Post subject: Re: Get name from one file and put it on another |
|
|
I see...
Getting a systematic summary should make things a bit easier, but I'm still gonna ask.
martix wrote: | I basically want the search pattern to work on one type of file and the replace pattern on another. - Like use a regex to match the source, then use a regex to match target and replace from the source. |
Is this functionality very hard to implement? I guess it will need work on the regex engine itself...
Or can it be done with user defined commands(python n' stuff)?  |
|
Back to top |
|
 |
admin Site Admin
Joined: 09 Mar 2007 Posts: 448 Location: Canada
|
Posted: Sat May 10, 2008 3:21 pm Post subject: |
|
|
This can be done with a User-Defined command (plugin).
Peter. |
|
Back to top |
|
 |
martix
Joined: 20 Apr 2007 Posts: 17
|
Posted: Sun May 11, 2008 4:49 pm Post subject: |
|
|
So... any guidelines? I am completely new to Python... |
|
Back to top |
|
 |
admin Site Admin
Joined: 09 Mar 2007 Posts: 448 Location: Canada
|
Posted: Sun May 11, 2008 9:49 pm Post subject: |
|
|
OK - I'll present an algorithm. If you think it's worth proceeding I can give you some sample python statements that should help.
0)
you'll have to define a list of regex pairs for each name that you want to search for as the source and each name that you want to replace (with the source)
potentialy this list could be as long as every name that has to be renamed. THis is why I question other use of a plugin since it would probably be less work to create an excel spreadsheet with a list of all old/new name pairs and import it for renaming.
1)
every plugin has a function called initforscan(). this is called by PFrank after a list of all candidate names have been scanned into a list. The list name is configurator.scanlist
2)
when initforscan is called, you can scan the entire list looking for the names that match regex1 and regex2. ALl the newnames can be calculated a this point and saved into a list with oldname/newname pairs.
3)
All the work is done at this point, YOu just have to get the names into the PFrank engine.
4)
After the initforscan() ic called, PFrank will itself go through the scanlist. It will pass you one name at a time for renaming using the fixnames() method. When this method is called you would just examine the name that was passed in and return the new name that you calclulated for that entry previously.
That's all there is to it. Step 1 is the most complicated part but not that bad.
Step 0 is the most work in my opinion. Unless I'm missing something, I think you would have to define 2 regex's for each name that you want to change in which case you might as well just define the old/new name pairs in an import file.
If you want to go ahead with a python plugin then let me know and I can give you some sample code.
Peter. |
|
Back to top |
|
 |
|