Saturday, July 22, 2017

#1 2017-01-02 07:01:05 am

Noovicio
Member
Registered: 2016-10-15
Posts: 12

moving a file to a variable folder

I'm stuck on this seemingly easy part of the code. I need to create a folder with the same filename than a file. The problem is I can't make it work when the folder is not a specific location but a variable. The file is an Indesign file created from a template therefore it has never being saved before...

Applescript:


tell application "Finder"
   set theFileName to "testText"
   set loc to "MAC:Users:miguelarias:Desktop:Stationery:Pending:"
   set newfo to make new folder at loc with properties {name:contents of theFileName}
   
   
end tell

tell application id "com.adobe.InDesign"
   tell active document
       save to "Users:miguelarias:Desktop:Stationery: Pending: newfo:" & theFileName
       move theFileName to newfo -----<<<---Here's the problem!!
   end tell
   tell application id "com.adobe.InDesign"
       close document 1
   end tell
end tell

Offline

 

#2 2017-01-02 08:20:17 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11453
Website

Re: moving a file to a variable folder

Hi,

you cannot use Finder item specifiers in an Indesign environment. You have to use string (HFS) paths

Applescript:

set pendingFolder to (path to desktop as text) & "Stationery:Pending:" -- relative path, works on every computer
set theFileName to "testText"
tell application "Finder"
   make new folder at folder pendingFolder with properties {name:theFileName}
end tell

tell application id "com.adobe.InDesign"
   save active document to (pendingFolder & theFileName & ":" & theFileName & ".indd")
   close document 1
end tell

Last edited by StefanK (2017-01-02 08:20:42 am)


regards

Stefan

Offline

 

#3 2017-01-02 08:51:08 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3111

Re: moving a file to a variable folder

StefanK wrote:

Hi,

you cannot use Finder item specifiers in an Indesign environment. You have to use string (HFS) paths

Applescript:

set pendingFolder to (path to desktop as text) & "Stationery:Pending:" -- relative path, works on every computer
set theFileName to "testText"
tell application "Finder"
   make new folder at folder pendingFolder with properties {name:theFileName}
end tell

tell application id "com.adobe.InDesign"
   save active document to (pendingFolder & theFileName & ":" & theFileName & ".indd")
   close document 1
end tell


As I am a lazy guy I would use :

Applescript:

set pendingFolder to (path to desktop as text) & "Stationery:Pending:" -- relative path, works on every computer
set theFileName to "testText"
tell application "Finder"
   set newfo to (make new folder at folder pendingFolder with properties {name:theFileName}) as text
   --> "MAC:Users:miguelarias:Desktop:Stationery:Pending:testText:"
end tell

tell application id "com.adobe.InDesign"
   save active document to (newfo & theFileName & ".indd")
   close document 1
end tell

Or, if inDesign accepts such syntax :

Applescript:

tell application id "com.adobe.InDesign"
   tell active document
       save it to (newfo & theFileName & ".indd")
       close it
   end tell
end tell

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) lundi 2 janvier 2017 14:51:00

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)