Skip to main content
added 1470 characters in body
Source Link

I'm using a program to capture image files and using AppleScript to write .jpgs from the raw camera files. This is executed when a button is clicked in our program.

im receiving weight data from a scale in the following format:

enter image description here

the following section of our script is trimming that down:

set thePath to "Macintosh HD:Users:Shared:CS:" if thePath is equal to thePath then -- Format the weight value to remove extra spaces and decimals set cleanWeightValue to do shell script "echo " & weightValue & " | sed 's/[^0-9.]//g'" -- Update Exif metadata with cleanWeightValue do shell script "/usr/local/bin/exiftool '-Description=je " & cleanWeightValue & " lbs' " & quoted form of POSIX path of thePath & "front.JPG" do shell script "/usr/local/bin/exiftool '-Caption-Abstract=je " & cleanWeightValue & " lbs' " & quoted form of POSIX path of thePath & "front.JPG" do shell script "/usr/local/bin/exiftool '-ImageDescription=je " & cleanWeightValue & " lbs' " & quoted form of POSIX path of thePath & "front.JPG" end if 

following this our weight reads in the following format in each image's metadata:

enter image description here

our goal is to also trim out those last two decimal points. wondering if this is possible building off our existing sed command

I'm using a program to capture image files and using AppleScript to write .jpgs from the raw camera files. This is executed when a button is clicked in our program.

im receiving weight data from a scale in the following format:

enter image description here

the following section of our script is trimming that down:

set thePath to "Macintosh HD:Users:Shared:CS:" if thePath is equal to thePath then -- Format the weight value to remove extra spaces and decimals set cleanWeightValue to do shell script "echo " & weightValue & " | sed 's/[^0-9.]//g'" -- Update Exif metadata with cleanWeightValue do shell script "/usr/local/bin/exiftool '-Description=je " & cleanWeightValue & " lbs' " & quoted form of POSIX path of thePath & "front.JPG" do shell script "/usr/local/bin/exiftool '-Caption-Abstract=je " & cleanWeightValue & " lbs' " & quoted form of POSIX path of thePath & "front.JPG" do shell script "/usr/local/bin/exiftool '-ImageDescription=je " & cleanWeightValue & " lbs' " & quoted form of POSIX path of thePath & "front.JPG" end if 

following this our weight reads in the following format in each image's metadata:

enter image description here

our goal is to also trim out those last two decimal points. wondering if this is possible building off our existing sed command

formatting
Source Link
Bodo
  • 6.4k
  • 18
  • 30

Currently working on a command in AppleScript to trim weight data we receive from a scale. We receive the weight in the following format X.XXX. lb. The Xs representing numbers. We're trimming out 6 spaces before the digits as well as 3 spaces,lb, and 5 more spaces.

Using the following command we've managed to trim characters and get the weight to read as X.XXX.. in our files metadata:

 | sed 's/[.^0-9]//g' 

We're hoping to also trim off the two decimal points following the thousandth character in the weight data. Unsure of where to go.

EDIT:

To help make it more clear what exactly is happening we are using a program to write image files on MacOS. The section of script I'm working on is to trim this weight data before exiftoolexiftool writes metadata for our image files. In my examples of the different states of the text above the "X"'sXs are all numbers that can always vary however the scale doesn't read past the thousandth decimal point. So after the first Decimal we will never get more than 3 numerical digits before the first decimal we may have up to 2 numerical digits in this case we would receive "XX.XXX"XX.XXX and would need to trim excess characters while not losing the numbers. hopefully this helps better understand the problem

if we weigh a package the scale sends the data to our program in the following:

" 1.392. lbs. "

 1.392. lbs. 

we've managed to get our script to trim this to "1.392.."1.392.. before writing metadata for the files. hoping to remove those last two decimals as well, while also making sure in the case of a weight reading being double digits i.e. "11.987"11.987 we can still perform the same trim.

Currently working on a command in AppleScript to trim weight data we receive from a scale. We receive the weight in the following format X.XXX. lb. The Xs representing numbers. We're trimming out 6 spaces before the digits as well as 3 spaces,lb, and 5 more spaces.

Using the following command we've managed to trim characters and get the weight to read as X.XXX.. in our files metadata:

 | sed 's/[.^0-9]//g' 

We're hoping to also trim off the two decimal points following the thousandth character in the weight data. Unsure of where to go.

EDIT:

To help make it more clear what exactly is happening we are using a program to write image files on MacOS. The section of script I'm working on is to trim this weight data before exiftool writes metadata for our image files. In my examples of the different states of the text above the "X"'s are all numbers that can always vary however the scale doesn't read past the thousandth decimal point. So after the first Decimal we will never get more than 3 numerical digits before the first decimal we may have up to 2 numerical digits in this case we would receive "XX.XXX" and would need to trim excess characters while not losing the numbers. hopefully this helps better understand the problem

if we weigh a package the scale sends the data to our program in the following:

" 1.392. lbs. "

we've managed to get our script to trim this to "1.392.." before writing metadata for the files. hoping to remove those last two decimals as well, while also making sure in the case of a weight reading being double digits i.e. "11.987" we can still perform the same trim.

Currently working on a command in AppleScript to trim weight data we receive from a scale. We receive the weight in the following format X.XXX. lb. The Xs representing numbers. We're trimming out 6 spaces before the digits as well as 3 spaces,lb, and 5 more spaces.

Using the following command we've managed to trim characters and get the weight to read as X.XXX.. in our files metadata:

 | sed 's/[.^0-9]//g' 

We're hoping to also trim off the two decimal points following the thousandth character in the weight data. Unsure of where to go.

EDIT:

To help make it more clear what exactly is happening we are using a program to write image files on MacOS. The section of script I'm working on is to trim this weight data before exiftool writes metadata for our image files. In my examples of the different states of the text above the Xs are all numbers that can always vary however the scale doesn't read past the thousandth decimal point. So after the first Decimal we will never get more than 3 numerical digits before the first decimal we may have up to 2 numerical digits in this case we would receive XX.XXX and would need to trim excess characters while not losing the numbers. hopefully this helps better understand the problem

if we weigh a package the scale sends the data to our program in the following:

 1.392. lbs. 

we've managed to get our script to trim this to 1.392.. before writing metadata for the files. hoping to remove those last two decimals as well, while also making sure in the case of a weight reading being double digits i.e. 11.987 we can still perform the same trim.

added 389 characters in body
Source Link

Currently working on a command in AppleScript to trim weight data we receive from a scale. We receive the weight in the following format X.XXX. lb. The Xs representing numbers. We're trimming out 6 spaces before the digits as well as 3 spaces,lb, and 5 more spaces.

Using the following command we've managed to trim characters and get the weight to read as X.XXX.. in our files metadata:

 | sed 's/[.^0-9]//g' 

We're hoping to also trim off the two decimal points following the thousandth character in the weight data. Unsure of where to go.

EDIT:

To help make it more clear what exactly is happening we are using a program to write image files on MacOS. The section of script I'm working on is to trim this weight data before exiftool writes metadata for our image files. In my examples of the different states of the text above the "X"'s are all numbers that can always vary however the scale doesn't read past the thousandth decimal point. So after the first Decimal we will never get more than 3 numerical digits before the first decimal we may have up to 2 numerical digits in this case we would receive "XX.XXX" and would need to trim excess characters while not losing the numbers. hopefully this helps better understand the problem

if we weigh a package the scale sends the data to our program in the following:

" 1.392. lbs. "

we've managed to get our script to trim this to "1.392.." before writing metadata for the files. hoping to remove those last two decimals as well, while also making sure in the case of a weight reading being double digits i.e. "11.987" we can still perform the same trim.

Currently working on a command in AppleScript to trim weight data we receive from a scale. We receive the weight in the following format X.XXX. lb. The Xs representing numbers. We're trimming out 6 spaces before the digits as well as 3 spaces,lb, and 5 more spaces.

Using the following command we've managed to trim characters and get the weight to read as X.XXX.. in our files metadata:

 | sed 's/[.^0-9]//g' 

We're hoping to also trim off the two decimal points following the thousandth character in the weight data. Unsure of where to go.

EDIT:

To help make it more clear what exactly is happening we are using a program to write image files on MacOS. The section of script I'm working on is to trim this weight data before exiftool writes metadata for our image files. In my examples of the different states of the text above the "X"'s are all numbers that can always vary however the scale doesn't read past the thousandth decimal point. So after the first Decimal we will never get more than 3 numerical digits before the first decimal we may have up to 2 numerical digits in this case we would receive "XX.XXX" and would need to trim excess characters while not losing the numbers. hopefully this helps better understand the problem

Currently working on a command in AppleScript to trim weight data we receive from a scale. We receive the weight in the following format X.XXX. lb. The Xs representing numbers. We're trimming out 6 spaces before the digits as well as 3 spaces,lb, and 5 more spaces.

Using the following command we've managed to trim characters and get the weight to read as X.XXX.. in our files metadata:

 | sed 's/[.^0-9]//g' 

We're hoping to also trim off the two decimal points following the thousandth character in the weight data. Unsure of where to go.

EDIT:

To help make it more clear what exactly is happening we are using a program to write image files on MacOS. The section of script I'm working on is to trim this weight data before exiftool writes metadata for our image files. In my examples of the different states of the text above the "X"'s are all numbers that can always vary however the scale doesn't read past the thousandth decimal point. So after the first Decimal we will never get more than 3 numerical digits before the first decimal we may have up to 2 numerical digits in this case we would receive "XX.XXX" and would need to trim excess characters while not losing the numbers. hopefully this helps better understand the problem

if we weigh a package the scale sends the data to our program in the following:

" 1.392. lbs. "

we've managed to get our script to trim this to "1.392.." before writing metadata for the files. hoping to remove those last two decimals as well, while also making sure in the case of a weight reading being double digits i.e. "11.987" we can still perform the same trim.

added 705 characters in body
Source Link
Loading
formatting
Source Link
Bodo
  • 6.4k
  • 18
  • 30
Loading
formatting
Source Link
Bodo
  • 6.4k
  • 18
  • 30
Loading
added 90 characters in body
Source Link
Loading
Source Link
Loading