Page 1 of 1
How to add file version to end of filename?
Posted: 08 Apr 2012 15:05
by sh4un
Hello,
Is it possible to have a custom command or script to add the file's version to the end of the filename?
If there wasn't any version info, then it would just add _[] to the end.
Examples:
ccleaner.exe to ccleaner_[2.100.2].exe
noversion.exe to noversion_[].exe
How do I achieve that? Right now I'm checking the version info via the preview and manually renaming and typing in the version info, which is a lot of work. If there is a way to speed it up / script it that would be much more efficient for me as I like to archive all the software I download. Any help/advise greatly appreciated.

Re: How to add file version to end of filename?
Posted: 08 Apr 2012 15:27
by Marco
Use the function rename and the variable <curver>.
Re: How to add file version to end of filename?
Posted: 08 Apr 2012 15:29
by Stefan
Hi and welcome.
Read this for an first help:
Help > Advanced Topics > Variables
<curver> " version of the current list item "
and
Help > Advanced Topics > Scripting Commands Reference
rename " Renames the currently selected List item(s) "
Examples
rename b, '*-<datem yyyymmdd>', p;
Appends the modified date to each of the selected items. With preview.
For an How to execute a script see my sig.
sh4un wrote:I like to archive all the software I download.
For that i copy the version incl. the release time stamp from the web page
and add this to the end of the download file in the "Save as..."-dialog.
Re: How to add file version to end of filename?
Posted: 08 Apr 2012 15:53
by sh4un
Thanks, that works just fine and was actually pretty simple!
rename b, '*_[<curver>]', p;
Re: How to add file version to end of filename?
Posted: 08 Apr 2012 15:58
by highend
And as a script if you want to select a few files, instead of one:
Code: Select all
if (get("CountSelected")<1){end 1, "Please select at least one file first!<crlf>Script quits.";}
$selectedItems = get("SelectedItemsPathNames", "|");
foreach($item, $selectedItems, "|") {
if($item == "") { break; }
$version = property("FileVersion", $item);
$extend = "" ? "_[]" : "_[".$version."]";
rename b, '*'.$extend, , $item;
}
Re: How to add file version to end of filename?
Posted: 08 Apr 2012 16:05
by sh4un
thanks highend, very good!

Re: How to add file version to end of filename?
Posted: 08 Apr 2012 16:18
by sh4un
highend, what's the difference between product version and file version? some files do not have the same values here, or use a different format like 6.3.2 and 6-3-2 etc.
Actually what I meant to say is why is there 2 different File versions on the preview pane version tab?
also, where exactly does XY get the file version info from if there is no version info on the properties dialog? Any one know?
Re: How to add file version to end of filename?
Posted: 08 Apr 2012 16:31
by highend
Because every developer can decide on his own which version string he wants to fill.
Just extend the script if you want to use either the first or the latter.