• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Converting MM to inches in text

Community Beginner ,
Apr 24, 2017 Apr 24, 2017

Copy link to clipboard

Copied

Hey guys,

I was wondering if there is an automated way, to conver mm in a document to i nches by running a script. See the below, i have tables and text like this:

Installation Dimensions (WxDxH)

224 x 534 x 667  mm

236 x 569 x 428.5 mm

231 x 600 x 430 mm

231 x 438 x 600 mm

255 x 486 x 404 mm

351 x 454 x 513 mm

It would be amazing life i could automate it rather then manually having to go the document through to do it.

Views

883

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 24, 2017 Apr 24, 2017

're you go. I didn't want to wait for that accuracy so I took the usual mils (3).

app.findGrepPreferences = null;

app.findGrepPreferences.findWhat = "\\d+(\\.\\d*)?\\s+x\\s+\\d+(\\.\\d*)?\\s+x\\s+\\d+(\\.\\d*)?\\s+mm\\b";

var list = app.activeDocument.findGrep( false);

while (list.length)

{

item = list.pop();

text = item.contents;

// mm to in at the end

text = text.replace('mm', 'inch')

// convert values

text = text.replace(/\d+(\.\d*)?/g, function(val) { return Math.round(1000*parseFloat(val)/25.4)/1000;

...

Votes

Translate

Translate
Community Expert ,
Apr 24, 2017 Apr 24, 2017

Copy link to clipboard

Copied

Piece of cake. Lots of such scripts already exist but someone can write it faster from scratch than you can find one online.

How many decimals of accuracy do you need?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 24, 2017 Apr 24, 2017

Copy link to clipboard

Copied

Just do a research on: Peter Kahrel or Steve Wareham!

(^/) 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Apr 24, 2017 Apr 24, 2017

Copy link to clipboard

Copied

https://forums.adobe.com/people/%5BJongware%5D  wrote

... someone can write it faster from scratch ...

... and I even know the name of that someone!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 24, 2017 Apr 24, 2017

Copy link to clipboard

Copied

're you go. I didn't want to wait for that accuracy so I took the usual mils (3).

app.findGrepPreferences = null;

app.findGrepPreferences.findWhat = "\\d+(\\.\\d*)?\\s+x\\s+\\d+(\\.\\d*)?\\s+x\\s+\\d+(\\.\\d*)?\\s+mm\\b";

var list = app.activeDocument.findGrep( false);

while (list.length)

{

item = list.pop();

text = item.contents;

// mm to in at the end

text = text.replace('mm', 'inch')

// convert values

text = text.replace(/\d+(\.\d*)?/g, function(val) { return Math.round(1000*parseFloat(val)/25.4)/1000; })

item.contents = text;

}

This is typical No Guarantees Software; make sure to save a copy first!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 24, 2017 Apr 24, 2017

Copy link to clipboard

Copied

Cool! … 

and Thanks!

(^/)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 27, 2024 May 27, 2024

Copy link to clipboard

Copied

Is there an updated version of this? I can't get it to run on anything recent, and my coding/scripting skills are pretty weak! 😆

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 28, 2024 May 28, 2024

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 28, 2024 May 28, 2024

Copy link to clipboard

Copied

Aww that's sad, sorry to learn this 😞

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 28, 2024 May 28, 2024

Copy link to clipboard

Copied

I tried this in InDesign 22 and 24 and it worked as expected.

What is the problem you encountered ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 28, 2024 May 28, 2024

Copy link to clipboard

Copied

I keep getting 'Santax Error. Expected expression, property or key form, etc. but found unknown token.'

No matter what I try, I can't get it compiled to save.

I'm trying in AppleScript, is this the right app? Or is it JS?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 28, 2024 May 28, 2024

Copy link to clipboard

Copied

LATEST

@Kit26140286tbo0

 

JS. 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines