WP-Filebase Pro › Forums › Templates › Version truncating the filename in the filebrowser.
- This topic has 4 replies, 2 voices, and was last updated 11 years, 2 months ago by fafdk.
- AuthorPosts
- 2013-08-09 at 11:31 #609fafdkParticipant
Version truncating the filename in the filebrowser.
Hi Fabian
I have a little problem after the scan, and it is with the filenames view in the filebrowser. Where can I remove the version function, which cuts the filename in half, if the filename has ex. 01.01.01-01.02.03.mp3 – it shows as 01.01.01 in the filelist and 01.02.03 as the version.
So what I’m looking for, is a way to disable “version” during the scan (rsync) process. Of course, I could go thought each file afterwards, and cut the version name and put it back to the file-name, but that would take me some time.
Thank you for the improvements.
2013-08-10 at 09:55 #617FabianParticipantIn classes/Admin.php, comment out theses lines:
$result = self::ParseFileNameVersion($file_name, $file->file_version); if(empty($file->file_version)) $file->file_version = $result['version']; if(empty($file->file_display_name)) $file->file_display_name = $result['title'];
2013-08-10 at 10:12 #619fafdkParticipantThx, but after I commented it out and ran a scan, it does not generate a filename anymore, just the path.
2013-08-10 at 18:51 #620fafdkParticipantI put the lines in again, and changed this line:
if(preg_match('/[-_\.]v?([0-9]{1,2}\.[0-9]{1,2}(\.[0-9]{1,2}){0,2})(-[a-zA-Z_]+)?$/', $fnwv, $matches)) {
`to this:
if(preg_match('/[\]v?([0-9]{1,2}\.[0-9]{1,2}(\.[0-9]{1,2}){0,2})(-[a-zA-Z_]+)?$/', $fnwv, $matches)) {
From here:
static function ParseFileNameVersion($file_name, $file_version) { $fnwv = substr($file_name, 0, strrpos($file_name, '.'));// remove extension if(empty($file_version)) { $matches = array(); if(preg_match('/[-_\.]v?([0-9]{1,2}\.[0-9]{1,2}(\.[0-9]{1,2}){0,2})(-[a-zA-Z_]+)?$/', $fnwv, $matches)) { $file_version = $matches[1]; if((strlen($fnwv)-strlen($matches[0])) > 1) $fnwv = substr($fnwv, 0, -strlen($matches[0])); } } elseif(substr($fnwv, -strlen($file_version)) == $file_version) { $fnwv = trim(substr($fnwv, 0, -strlen($file_version)), '-'); } $title = WPFB_Core::GetOpt('no_name_formatting') ? $fnwv : wpfb_call('Output', 'Filename2Title', array($fnwv, false), true); return array('title' => empty($title) ? $file_name : $title, 'version' => $file_version); }
Maybe it’s a rough hack, but it seems to work.
I’ll wait for a proper update.
/FAF
2013-08-10 at 20:11 #621fafdkParticipantMaybe an option to turn off the “automatic versionering from filename” would be a nice feature to have? – and/or to choose which symbols would be used in the filename.
- AuthorPosts
- You must be logged in to reply to this topic.