Peters Flexible RenAmiNg Kit (PFrank) Forum Index Peters Flexible RenAmiNg Kit (PFrank)
Support and Discussion Site for the PFrank File/Folder Renaming Tool (***NEW HOME PAGE*** "http://pfrank.atwebpages.com")
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Decimal to Hexadecimal Replacment/Conversion - Help

 
Post new topic   Reply to topic    Peters Flexible RenAmiNg Kit (PFrank) Forum Index -> General Support
View previous topic :: View next topic  
Author Message
gisnar



Joined: 07 Aug 2008
Posts: 9
Location: Canada

PostPosted: Thu Aug 07, 2008 9:08 pm    Post subject: Decimal to Hexadecimal Replacment/Conversion - Help Reply with quote

Hi,

I'm a new user and find the program a bit daunting. What I'd like to do at this time is to rename a number of video files from Name1hhh.mpg to Name2ddd.mpg, where hhh and ddd are hexadecimal and decimal equivalent numbers respectively. It appears that I can do this by means of a search pattern list. One item for Name1 to Name2 and one each for each of the hex to decimal number conversions, e.g. 00A to 010.

However, this seems to be a very cumbersome way to do it; there must be a much better method, but I haven't been able to figure it out. In a previous post there was mention of setting the number base (which may be related to what I'm trying to do), but I haven't been able to find anything useful on this in the Help section.

Any help on this would be greatly appreciated. By the way the program looks awesome, and I'm sure it's just a matter of getting into it.

Thanks in advance.
Gisnar
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 09 Mar 2007
Posts: 448
Location: Canada

PostPosted: Fri Aug 08, 2008 1:56 am    Post subject: Reply with quote

The best way to do this is with a plugin.

Since it was fairly simple, I've made one available at:

http://www3.telus.net/pfrank/PFrank_ConvertHextoDec_Plugin.py

This will convert any 3 digit hex number at the end of a name to a decimal number.
Copy the file and follow the instructions at the top of the file (ie. rename to PFrankUser.py and move it to your install folder; then start PFrank.
When you insert the user command into the custom list, use the
"ALL* option.

Hope that helps.
Let me know if you need more info.

Peter.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gisnar



Joined: 07 Aug 2008
Posts: 9
Location: Canada

PostPosted: Fri Aug 08, 2008 5:17 pm    Post subject: Reply with quote

Hi Peter,

Thanks very much for creating a plugin for this purpose. I have followed the instructions at the top of the file and copied just the class definition to the PFrankUser.py file (pre-existing in the PFrank folder). I used MS NotePad to do this and added this new text at the end of the file (hope this makes sense).

With respect to "add a reference to the class in the PFrankUser.py 'UserRenamerList' table", I have added the following at the end of that table:
UserConvertHexToDec(), # object created for hex to decimal conversion

If this is not correct/appropriate, can you provide additional instructions for what to do and how to do it?

Once the plugin is set up correctly, how do I activate its functionality in PFrank?

Another question: When I run PFrank, I get the following message: "2 instances of the PFrank GUI have been detected. It is strongly recommended to only run one instance to avoid conflicts with the current configuration file. Proceed anyway?" What's causing this? I have been proceeding anyway and have not noticed any undesirable side effects.

Thanks in advance.
gisnar
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 09 Mar 2007
Posts: 448
Location: Canada

PostPosted: Sat Aug 09, 2008 3:42 am    Post subject: Reply with quote

Looks like you had an instance of PFrank running in the background.
Not sure how that would happen without you noticing (was it not visible in the system tray?).
You should exit the second PFrank instance and then use the windows task manager to kill the first instance (just google 'windows task manager' if you've never used it).

What you did with the PFrankUser.py is correct. Now when you run PFrank you should see verification messages in the bottom summary panel indicating that the plugin has been successfully installed.
If this fails then please send me the summary information.

If the plugin is successfully installed, then you should see the plugin command at the top of the pre-defined command list (when you pull it down with the mouse).
Once selected from the list, press the 'Insert' button which will place the command in the custom list. Then press scan.\

Let me know if you have any problems.

Peter.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gisnar



Joined: 07 Aug 2008
Posts: 9
Location: Canada

PostPosted: Sat Aug 09, 2008 3:58 am    Post subject: Reply with quote

Peter,

I have managed to figure out how to use the new plugin on my own. However, I do have a follow-up question that I will come back to in a few days. I will be travelling in the meantime and will not have Internet access.

Until then, if you would address the final question in my previous post, it would be greatly appreciated.

Thanks,
gisnar
Back to top
View user's profile Send private message
gisnar



Joined: 07 Aug 2008
Posts: 9
Location: Canada

PostPosted: Sat Aug 09, 2008 4:03 am    Post subject: Reply with quote

Sorry, I did not see your most recent post. Will look at it as soon as I have a chance.
Back to top
View user's profile Send private message
gisnar



Joined: 07 Aug 2008
Posts: 9
Location: Canada

PostPosted: Mon Aug 11, 2008 1:47 am    Post subject: Reply with quote

Peter,

The plugin works according to the request I made initially. However, at that time I did not want to make things too complicated. In actual fact, the full story is that I need the following renaming done:

From: "Name1hhh_n.mpg"
To: "Name2ddd_n.mpg"
where n is a hex digit (I assume, although I have never seen anything above 4 or 5). Sometimes "_n" is not present. By the way, would it be possible to keep leading zeroes in the decimal number?

As suggested above, "Name1hhh.mpg" to "Name2ddd.mpg" now works fine. I'm thinking that it is the statement below in the plugin that needs to be changed, but I don't know what to change.

self.firstHexNumber = re.compile(r"""
^(.*?)([0-9a-fA-F]{3,3})([.].*)$ # look for 3 digit hex number at end of the string (before the extension)
""", re.VERBOSE)

The issue regarding multiple instances of PFrank running, resolved itself when I rebooted the computer. I was not aware of another instance of the program running. Nothing showed up in the Task Manager. Anyway, it's no longer a problem.

Thanks,
gisnar
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 09 Mar 2007
Posts: 448
Location: Canada

PostPosted: Mon Aug 11, 2008 6:19 am    Post subject: Reply with quote

Hi,

The line you highlighted needs to be changed to:

self.firstHexNumber = re.compile(r"""
^(.*?)([0-9a-fA-F]{3,3})([.].*)$ # look for 3 digit hex number
""", re.VERBOSE)


To get the leading zeros, change the line with the following:

newnumber = "%d"%(number)

to

newnumber = "%06d"%(number)

That should do it!
Let me know if you have any other questions.

Peter.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gisnar



Joined: 07 Aug 2008
Posts: 9
Location: Canada

PostPosted: Tue Aug 12, 2008 12:52 am    Post subject: Reply with quote

Peter,

Thanks very much for the additional information. I decided to make one change at a time and started with the one to give me the leading zeroes. However, after editing the PFrankUser.py file and restarting PFrank, I get an error and have not been able to resolve it. Here is the error message sequence:

Error: Cannot Reload/ReImport 'PFrankUser.py' User Configuration File.

Stack Trace:
============
Traceback (most recent call last):
File "SearchRepGui.pyo", line 610, in ValidateUserFile
File "C:\Program Files\PFrank\PFrankUser.py", line 1175, in ?
NameError: name 'UserConvertHexToDec' is not defined

Hopefully you can tell me what I'm doing wrong.

Regarding the other change, I have very carefully compared the old statement to the proposed new one and I have not been able to identify any difference - they look identical. Could you look at this as well?

Thanks,
gisnar
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 09 Mar 2007
Posts: 448
Location: Canada

PostPosted: Tue Aug 12, 2008 2:10 am    Post subject: Reply with quote

Ooops - I had a cut/paste error with the line change. Sorry about that.

Change :

^(.*?)([0-9a-fA-F]{3,3})([.].*)$

to

^(.*?)([0-9a-fA-F]{3,3})([_].*)$

It's essentially changing the [.] to a [_].

For the stack trace error it's complaining that UserConvertHexToDec (probably referenced in the UserRenamerList table at line 1175?) does not exist. Can you verify if the UserConvertHexToDec class still has the same name? If not, then please email me the PFrankUser.py file and I'll try it out.

Peter.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gisnar



Joined: 07 Aug 2008
Posts: 9
Location: Canada

PostPosted: Wed Aug 13, 2008 1:04 am    Post subject: Reply with quote

I have still not been able to find the problem. As a result, I have sent you a copy of the PFrankUser.py file by email.

Thanks,
gisnar
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 09 Mar 2007
Posts: 448
Location: Canada

PostPosted: Wed Aug 13, 2008 1:38 pm    Post subject: Reply with quote

I received your PFrankUser.py file, fixed the problem, and sent it back to you. The probelm was that the class definition was declared after the 'UserRenamerList' Table. I also updated the search expression to look for the '_' delimiter after the hex number and set up the decimal number to be displayed with up to 5 leading zeros.

Let me know if that works for you.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gisnar



Joined: 07 Aug 2008
Posts: 9
Location: Canada

PostPosted: Wed Aug 13, 2008 4:44 pm    Post subject: Reply with quote

Hi Peter,

Thanks very much - that fixes the problem!

However, there is still one outstanding issue. As mentioned in my earlier posts, the folder in which I am renaming files contains two slightly different types of names:

1. Namehhh_n.mpg, where hhh is a 3 digit hex number and n is a single digit hex number.

2. Namehhh.mpg, where hhh is again a 3 digit hex number (effectively this is Namehhh_0.mpg, but the _0 has been omitted).

Currently the plugin takes care of item 1, but not item 2. The original plugin you prepared, renamed item 2 correctly, but not item 1. Can this be corrected with an OR of the following statements?

^(.*?)([0-9a-fA-F]{3,3})([.].*)$

and

^(.*?)([0-9a-fA-F]{3,3})([_].*)$

Thanks in advance and sorry for dragging this out so long. I greatly appreciate your help!
gisnar
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 09 Mar 2007
Posts: 448
Location: Canada

PostPosted: Thu Aug 14, 2008 2:25 am    Post subject: Reply with quote

Just change the [.] to a [._]

that should do it!

Peter.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gisnar



Joined: 07 Aug 2008
Posts: 9
Location: Canada

PostPosted: Thu Aug 14, 2008 3:12 am    Post subject: Reply with quote

Great - now it works perfectly! With this I can now rename all my video files (about 400) with just a few keystrokes. By the way, the files are off a JVC GZ-HD7 high def camcorder. When transferring the files to my PC it creates these awful file names.

Thanks again very much for all your help.
gisnar
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Peters Flexible RenAmiNg Kit (PFrank) Forum Index -> General Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group. Hosted by phpBB.BizHat.com


Start Your Own Video Sharing Site

Free Web Hosting | Free Forum Hosting | FlashWebHost.com | Image Hosting | Photo Gallery | FreeMarriage.com

Powered by PhpBBweb.com, setup your forum now!
For Support, visit Forums.BizHat.com