'Convert duration string into seconds integer

I want to turn strings that represent durations into their duration in seconds as an integer.

All of the strings are formatted in the following way:

hh:mm:ss

I was working with substrings, which I cast to integers and then multiplied with 3600, 60 or 1 respectively and in the end summed everything up.

Just like this:

SELECT cast(substr(time_string, 1, 2) as smallint) * 3600 + cast(substr(time_string, 4, 2) as smallint) * 60 + cast(substr(time_string, 7, 2) as smallint) as seconds from table_name

As I have to do this for multiple fields, I would be interested in a better way to achieve this result. My search for a better solution, though, fell flat so far.

I would appreciate any input or help!



Solution 1:[1]

If you are looking to move only the files in the folders and not the folders themselves. This following AppleScript code is one way to achieve your goal.

activate
set searchFolder to choose folder with prompt "Choose The Folder To Search"

activate
set destinationFolder to choose folder with prompt "Choose The Folder To Move Files To"

tell application "Finder"
    set theFiles to (files of entire contents of searchFolder) as alias list
    move theFiles to destinationFolder
end tell

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 wch1zpink