# Change %\_length% to HH:mm:sec

**URL:** https://community.mp3tag.de/t/change-length-to-hhsec/60417
**Category:** Support
**Created:** [March 18, 2023, 8:32pm UTC](https://community.mp3tag.de/t/change-length-to-hhsec/60417 "2023-03-18T20:32:13Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![xpac5896a](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/x/85f322/32.png) [@xpac5896a](https://community.mp3tag.de/u/xpac5896a)
#### Post date: [March 18, 2023, 8:32pm UTC](https://community.mp3tag.de/t/change-length-to-hhsec/60417/1 "2023-03-18T20:32:13Z")

</div>

Somebody was nice enough to show me how to change %\_length% to hours minutes and seconds when exporting to CSV. Unfortunately, when I downloaded the latest version, the CSV format was changed back to the original and I must start all over again. Can anyone pleased help in changing it back to the hour, minute, second format?

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [March 18, 2023, 8:38pm UTC](https://community.mp3tag.de/t/change-length-to-hhsec/60417/2 "2023-03-18T20:38:02Z")

</div>

> [@xpac5896a](#):
>
> when exporting to CSV

Do you mean this thread?

> [@Adding Length (time) to CSV](https://community.mp3tag.de/t/adding-length-time-to-csv/55643):
>
> I'm wanting to add the length (time) of a track for export using csv. Length is nothing more than the time it would take a track to play. I'm not a programmer but I do know it can be done but I have no idea how to do it. Any help would be greatly appreciated

And: an update installation usually does not overwrite the existing user-defined exports and actions.

---

<div class="post-metadata">

### Author: ![xpac5896a](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/x/85f322/32.png) [@xpac5896a](https://community.mp3tag.de/u/xpac5896a)
#### Post date: [March 19, 2023, 12:53pm UTC](https://community.mp3tag.de/t/change-length-to-hhsec/60417/3 "2023-03-19T12:53:52Z")

</div>

ohrenkino:  
I wish I had a screen shot of my original CSV export file and the existing one after updating MP3 Tag, If I did, I wouldn't be asking this question. The CSV file can be made to include HH:mm:ss as shown here  
 ![Example](https://community.mp3tag.de/uploads/default/original/2X/9/964d6a02de3884216068eeca40d206221d51f39f.jpeg)  
and is included in the CSV file and will export perfectly into Excel with no problem at all. The expression used can be put anywhere in the CSV export file and will work. I just wish I had kept his reply to my question, my bad.

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [March 19, 2023, 12:59pm UTC](https://community.mp3tag.de/t/change-length-to-hhsec/60417/4 "2023-03-19T12:59:30Z")

</div>

As far as I can remember, the problem arose from Excel and its display of the time.  
I think you have to configure the Excel column to show always the hours.

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [March 19, 2023, 1:28pm UTC](https://community.mp3tag.de/t/change-length-to-hhsec/60417/5 "2023-03-19T13:28:36Z")

</div>

If you want to define your own calculation you could try:

`$ifgreater(%_length_seconds%,3600,$div(%_length_seconds%,3600):$div($sub(%_length_seconds%,3600),60):$mod(%_length_seconds%,60),00:$num($div(%_length_seconds%,60),2):$num($mod(%_length_seconds%,60),2))`

I am too stupid - this is the much easier way:  
`$ifgreater(%_length_seconds%,3600,%_length%,00:%_length%)`

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [March 19, 2023, 3:40pm UTC](https://community.mp3tag.de/t/change-length-to-hhsec/60417/6 "2023-03-19T15:40:12Z")

</div>

> [@ohrenkino](#):
>
> $ifgreater(%\_length\_seconds%,3600,%\_length%,00:%\_length%)

That `HH:mm:ss` length formatting works great, exported in a CSV file, later imported in LibreOffice Calc (v7.0.5.3):

 ![image](https://community.mp3tag.de/uploads/default/original/2X/4/49ddc3bbdd96b5fb549fdb8d458d3ffee5e5342b.png)

In Excel 2021 the import of the same CSV file needs more manual work.  
For example, the TRACK column content needs to be manually adjusted. As you can see, Excel converts some TRACK numbers into a short date for some values. Example for the same CSV as above (unedited, original imported):

 ![image](https://community.mp3tag.de/uploads/default/original/2X/8/8a52467e98565f59ad72f6a2ea8baac03b1325f2.png)

---

<div class="post-metadata">

### Author: ![xpac5896a](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/x/85f322/32.png) [@xpac5896a](https://community.mp3tag.de/u/xpac5896a)
#### Post date: [March 19, 2023, 4:04pm UTC](https://community.mp3tag.de/t/change-length-to-hhsec/60417/7 "2023-03-19T16:04:50Z")

</div>

ohrenkino;  
You stated in your last email  
"As far as I can remember, the problem arose from Excel and its display of the time. I think you have to configure the Excel column to show always the hours".  
This is an impossibility as when you open your CSV file it opens in a different window you cannot format the column. The expression must be in the CSV string. I know Excel has problems with time especially when importing and can be very frustrating, but I know it can be done within the CSV string. I know somebody said that when you install the latest version it does not delete any export functions, but it does. I'm going to try your expression you posted and see what happens only this time, if it works, and I have no doubt it will, I'll make a copy which I should have done in the first place.

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [March 19, 2023, 4:07pm UTC](https://community.mp3tag.de/t/change-length-to-hhsec/60417/8 "2023-03-19T16:07:24Z")

</div>

> [@xpac5896a](#):
>
> This is an impossibility as when you open your CSV file it opens in a different window you cannot format the column.

You have to avoid the automatism in Windows to just double-click on a csv file but open it from within Excel and then use the import assistant. In that assistant you can set how Excel should treat the data.

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [March 19, 2023, 4:10pm UTC](https://community.mp3tag.de/t/change-length-to-hhsec/60417/9 "2023-03-19T16:10:26Z")

</div>

> [@xpac5896a](#):
>
> I know somebody said that when you install the latest version it does not delete any export functions, but it does.

I am still convinced that the installation of a new MP3tag version does not delete the user settings as long as you stay in the same kind of installation mode (standard vs. portable) and install the same kind of architecture (32-bit vs. 64-bit).  
For all other installation variations, please see

> [@Notes on the 64-bit version of Mp3tag](https://community.mp3tag.de/t/notes-on-the-64-bit-version-of-mp3tag/57250):
>
> I've released a [64-bit version of Mp3tag](https://community.mp3tag.de/t/455) a few days ago and received a few questions about differences between the 32-bit version and the 64-bit version. To make it short, there should not be any noticeable differences except for two things: The 64-bit version uses 64-bits to address memory and is no longer limited to 2 GB per application. While the [Library](https://docs.mp3tag.de/customization/options/library) feature of Mp3tag is already a very viable solution for large libraries, loosening the memory restriction is one of the key benefits of …

and

> **[Download and Installation – Mp3tag Documentation](https://docs.mp3tag.de/getting-started/installation/)**
>
> Details on where to download Mp3tag, Mp3tag's different installation modes, and system requirements for the usage of Mp3tag. Mp3tag is the universal Tag Editor.

So unless you have erased substantial parts of your data storage, the old settings should still be there.  
Possible locations are described in the documentation.

---

<div class="post-metadata">

### Author: ![xpac5896a](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/x/85f322/32.png) [@xpac5896a](https://community.mp3tag.de/u/xpac5896a)
#### Post date: [March 19, 2023, 4:29pm UTC](https://community.mp3tag.de/t/change-length-to-hhsec/60417/10 "2023-03-19T16:29:14Z")

</div>

ohrenkino:  
Regarding installation of new versions, I always get the Install version for Windows and if it's 64bit, which I'm using, I grab it. I can always uninstall MP3tag and show you the CSV as it pertains to a new install. Trust me, if it didn't change any parameters in the CSV export, I wouldn't.be here trying to find out how to change anything as I keep the export string the same until I install an updated version. As far as you string that you created, it works perfectly and I'm grateful for you taking your time and figuring this out. Thank you very much. (This time I'll, make a copy)

---

<div class="post-metadata">

### Author: ![xpac5896a](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/x/85f322/32.png) [@xpac5896a](https://community.mp3tag.de/u/xpac5896a)
#### Post date: [March 19, 2023, 5:00pm UTC](https://community.mp3tag.de/t/change-length-to-hhsec/60417/11 "2023-03-19T17:00:05Z")

</div>

Well, I spoke too soon. Here is the string I'm using:

```auto
$filename(csv,utf-16)Year;Title;Artist;Album;Track;Length;Genre;Comment;
$loop(%_filename_ext%)%year%;%title%;%artist%;%album%;%track%;$ifgreater(%_length_seconds%,3600,%_length%,00:%_length%);%genre%;%comment%;
$loopend()build on %_date% with %_app% - the universal Tag editor - http://www.mp3tag.de/en/.

```

For some reason it will not export the CSV file. I keep getting an error message say it cannot write the file. I've looked at the string and can't figure what the heck is going on. It originally wrote it but I was missing a parameter which was "Artist". As soon as I put that back into the string, it quit exporting. Maybe you can figure it out cause I surely don't know what the problem is.

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [March 19, 2023, 5:05pm UTC](https://community.mp3tag.de/t/change-length-to-hhsec/60417/12 "2023-03-19T17:05:50Z")

</div>

> [@xpac5896a](#):
>
> error message say it cannot write the file

Please check if this file is still open in Excel or an editor. You can not overwrite it, if it is still in use.

The string itself works fine in my environment with my files.

---

<div class="post-metadata">

### Author: ![xpac5896a](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/x/85f322/32.png) [@xpac5896a](https://community.mp3tag.de/u/xpac5896a)
#### Post date: [March 19, 2023, 5:40pm UTC](https://community.mp3tag.de/t/change-length-to-hhsec/60417/13 "2023-03-19T17:40:38Z")

</div>

OK, I screwed up. I had a CSV file already open and that's why I was getting the error. What else can go wrong? Today has not been good for me. Think I'll just start over again. The string works perfectly.

---

<div class="post-metadata">

### Author: ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)
#### Post date: [April 18, 2023, 5:41pm UTC](https://community.mp3tag.de/t/change-length-to-hhsec/60417/14 "2023-04-18T17:41:07Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
