How to add file version to end of filename?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
sh4un
Posts: 15
Joined: 07 Apr 2012 18:05

How to add file version to end of filename?

Post 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.

:)
XYplorer LLP

Marco
Posts: 2354
Joined: 27 Jun 2011 15:20

Re: How to add file version to end of filename?

Post by Marco »

Use the function rename and the variable <curver>.
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: How to add file version to end of filename?

Post 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.

sh4un
Posts: 15
Joined: 07 Apr 2012 18:05

Re: How to add file version to end of filename?

Post by sh4un »

Thanks, that works just fine and was actually pretty simple!

rename b, '*_[<curver>]', p;
XYplorer LLP

highend
Posts: 14338
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: How to add file version to end of filename?

Post 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;
	}
One of my scripts helped you out? Please donate via Paypal

sh4un
Posts: 15
Joined: 07 Apr 2012 18:05

Re: How to add file version to end of filename?

Post by sh4un »

thanks highend, very good! :P
XYplorer LLP

sh4un
Posts: 15
Joined: 07 Apr 2012 18:05

Re: How to add file version to end of filename?

Post 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?
XYplorer LLP

highend
Posts: 14338
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: How to add file version to end of filename?

Post 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.
One of my scripts helped you out? Please donate via Paypal

Post Reply