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 

Sorting collections with csv and crc

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



Joined: 28 Feb 2008
Posts: 4

PostPosted: Fri Feb 29, 2008 10:00 pm    Post subject: Sorting collections with csv and crc Reply with quote

About sorting big collections.
Can I (or someone else) make a CSV-file of a nicely sorted collection of files, and then use that CSV-file on a messy collection which contains largely the same files as the tidy collection, to get the messy collection sorted nicely?
All done with your program.
Back to top
View user's profile Send private message
Chotor



Joined: 28 Feb 2008
Posts: 4

PostPosted: Fri Feb 29, 2008 10:01 pm    Post subject: Reply with quote

Quote:
Yes you can import csv files. The first column has to
have the full path to the current file, the second
column requires the new file name (or full path to the
new file name).

Just pull down the file menu on the main window and
select "Import rename list from...".

Hope that helps.
Back to top
View user's profile Send private message
Chotor



Joined: 28 Feb 2008
Posts: 4

PostPosted: Fri Feb 29, 2008 10:08 pm    Post subject: Reply with quote

My problem is a bit more difficult than that.

I would like something like this:
The program loads the sorted csv (with crc32 values), scans the first file of unsorted collection, compares it's crc32 with values in the sorted csv, finds a matching value, renames the first file (with path and filename) to the name in the sorted csv.
Then the same with the second file, the third file, .... , the n-th file. Recursively.
All until the previously unsorted collection has the same directory structure and naming convention as the sorted collection/csv.

Can that be done?

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


Joined: 09 Mar 2007
Posts: 448
Location: Canada

PostPosted: Sat Mar 01, 2008 4:50 am    Post subject: Reply with quote

If I understand you correctly then yes it can be done but you will need a plugin (user-defined command).

Assumptions:
1)
The nice and messy collections of files are in different folders.

Steps:
0)
Install the fancy-smancy plugin that I will describe later.
1)
Set the current folder to the folder with the nice file collection. Insert the 'insert file hash before' pre-defined command into the custom renaming list of the main window. In the Options window, configure the crc32 value to be inserted.
2)
Press the scan button. The preview window will pop up. The newnames should be the same as the old but will have the crc32 values prefixed in front of the name. Instead of renaming at this point, just use the 'export all columns to csv' menu item. Beforehand you might want to remove the columns you don't care about.
3)
Manually manipulate the csv file so that the new names are in the first column of the csv. Insert dummy names into the second column.
4)
Now go back to the PFrank main window, change the current folder to the folder with the messy collection and clear the custom renaming list.
Insert the command that was installed by your plugin (eg. name of command could be 'crc correlator')
5)
Press scan and the preview window will come up. Do some manual verification, press rename, and you are done!

The obvious question is what did the plugin do?
Answer:
The plugin, as a pre-configuration (this is part of the plugin API), opened your csv file, read the names out of it extracting the crc info from the names. The plugin builds a hash list of the filenames (i.e. the original names without the crc prefix) mapped to their crc values.
After the preconfiguration has run, the scanned names are passed to the plugin one at a time (the handler for this is also part of the API). The plugin opens the file, calculates the crc32, then compares to the entries in the hash list, and if it finds a match will use the found hash table name as the new name for the file.
This will happen for each file. After completion, the preview list will come up with the old names mapped to the calculated new names.
If you have programming experience, you should be able to write the plugin. The pfrank plugins need to be written in Python. I can provide you with some assistance if you like especially with the API.

Hope I understood your query correctly. If so, I hope the proposed solution is understandable.

Peter.


Last edited by admin on Sun Mar 02, 2008 9:07 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Chotor



Joined: 28 Feb 2008
Posts: 4

PostPosted: Sun Mar 02, 2008 12:50 am    Post subject: Reply with quote

I think you understood me.
All I want to do is to have a nice sorted csv (pre-made), and use this on a bunch of files to sort the matching files (those that match by crc32) to nice, tidy filenames.
Let's say I had 100 mp3s of 10 different artists, all with strange filenames. If someone had the same files, only nicely sorted, he could export his csv, and then I could use that csv to rename my files with just one click!

It seems to me this is what you are describing here.

The problem is that I have to write the plugin. I have some programming experience, but really don't know where to start with this.
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 09 Mar 2007
Posts: 448
Location: Canada

PostPosted: Mon Mar 03, 2008 4:42 pm    Post subject: Reply with quote

I don't have the time to write/test the plugin (user defined command) but hopefully I can get you started. Below is a rough development plan:
1)
Read the built-in help section describing user-defined commands.
2)
try to install the sample plugin. Use the 'edit' plugin control (first you will
likely have to associate an editor with .py files). Even better is if you first
install python 2.4.4 - afterwards '.py' files can be opened with the IDLE editor.
The plugin file is in your install folder - the help info should tell you more
about the file
Use the 'Verify' plugin control to install the plugins.
3)
play around with the sample plugins until you are comfortable with them - change the name, change the functionality.
4)
Once you've done that and become familiar with how the plugins work, you should be ready to
write your own.
You will need to import the csv (for opening/reading csv files) and zlib
(for calculating crc32) modules. Both modules are already available with PFrank. Use google for information about the modules.
5)
The plugin file has a header which describes the API.
A rough algorithm for the new plugin would be:
a)
In the preprocessing 'initforscan' section, open the csv file.
read one line at a time. Each line has a name. Extract the crc number from each name.
store the name and crc in a data dictionary (same as a hash table). YOu can use google to find sample
code for reading csv files.
You could need compile a regex variable for parsing the crc number from
the name or you could do some other string manipulation.
b)
In the fixnames section, take the filename that is passed in, use the zlib library to calulate its crc,
search for hte crc in the data dictionary that was set up previously. IF the crc is found, then
return the name associated with the crc.

I can help you with steps 5a) and b) with some sample code when you are ready (assuming you want to undertake the creation of the plugin).

Hope this helps. Let me know if you have any trouble with steps 1-3 as I may have to update the associated help sections accordingly.

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



Joined: 23 Mar 2010
Posts: 1

PostPosted: Tue Mar 23, 2010 8:18 am    Post subject: Reply with quote

Is available csv a sort file (2 columns if in excel to open):
The dead person (Dead Man cd2) (1995); v: \_ Kino\Filmy (on genres) \05 Vesterny\Mertvets (Dead Man) \Dead man (2).avi

Open open space (Open Range) (2003); v: \_ Kino\Filmy (on genres) \05 open space Vesterny\Otkrytyj (Open Range) \Otkritiy. Prostor. (2003.RUS.BDRip.XviD.AC3.-HQ-ViDEO.avi

The magnificent seven (The Magnificent Seven cd1) (1960); v: \_ Kino\Filmy (on genres) / magnificent \05Vesterny seven \The Magnificent Seven CD1.avi
Separator; but it is possible and to change if it is necessary.


Etc.
Some thousand such strings. All files lie in one directory v: \_ Kino\Filmy (on genres) \

How it is possible to rename all files from 2 columns names from 1 column?
That is I wish to have a file Open open space (Open Range) (2003).avi

I press File-Import Rename list from
I select a file - and occurs nothing.
What sort should have csv a file and what customisations in the program?
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