Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › Indesign CS5.5/CS5 backsave script
New Posts  All Forums:Forum Nav:

Indesign CS5.5/CS5 backsave script

post #1 of 2
Thread Starter 
Hey all, I'm trying to write a script that..
1. Watches folder A for *.indd documents (will always be CS5 or CS5.5 file)
2. Determines version of indd file
3. Opens in appropriate version of Indesign and exports/saves the file as an IDML (i.e compatible with CS4) to folder B.
4. Moves the original indd file to folder B.

Trying to write it in Javascript, will be running on a Mac. Indesign's implementation of Javascript is doing my head in any more details needed?
Blitzkrieg
(14 items)
 
  
CPUMotherboardGraphicsRAM
i7 980X Asus P6X58D Premium GTX 680 G.Skill 6Gb 2000Mhz 
Hard DriveOptical DriveCoolingOS
OCZ Vertex 3 BD/DVD Combo EK Supreme HF Windows 7 
MonitorKeyboardPowerCase
SAMSUNG S27A850T 27" Microsoft basic 600 :p AeroCool V12 1000W HAF 932 
Mouse
Razer Deathadder V2 
  hide details  
Reply
Blitzkrieg
(14 items)
 
  
CPUMotherboardGraphicsRAM
i7 980X Asus P6X58D Premium GTX 680 G.Skill 6Gb 2000Mhz 
Hard DriveOptical DriveCoolingOS
OCZ Vertex 3 BD/DVD Combo EK Supreme HF Windows 7 
MonitorKeyboardPowerCase
SAMSUNG S27A850T 27" Microsoft basic 600 :p AeroCool V12 1000W HAF 932 
Mouse
Razer Deathadder V2 
  hide details  
Reply
post #2 of 2
Thread Starter 
Got the backsave part working in Java, but decided to use Applescript because it can move/modify/delete files much easier. Here it is in both languages, note first script is obviously incomplete.
Code:
myFolder = new Folder("/test");
docArray = myFolder.getFiles ('*.indd');
if(docArray.length>0)
{
    for(i=0; i<docArray.length; i++)
    {
            app.open(File (docArray[i]));
            app.activeDocument.exportFile(ExportFormat.INDESIGN_MARKUP, File(myFolder.fsName + "/converted/" + app.activeDocument.name.split(".indd")[0] + ".idml"), false);
            app.activeDocument.close(SaveOptions.no);
    }
}
Code:
on idle
try
tell application "Finder"
set newLoc to "SpamTrap HD:Backsave:converted" as alias
set docLoc to "SpamTrap HD:Backsave" as alias
set docArray to (name of every file of docLoc whose name extension is "indd") as list
set fileCheck to (count of (every file of docLoc whose name extension is "indd"))
end tell
on error errmsg number errnum
do shell script "logger Backsaver - " & errnum & errmsg
end try

if fileCheck is greater than 0 then
try
repeat with i in docArray
set tmp to (reverse of (characters of i)) as string
set fName to (reverse of (characters ((offset of "." in tmp) + 1) thru -1 of tmp)) as string
set fileInfo to (get info for ((docLoc & i as string) as alias))
set fileSize to size of fileInfo
delay 1
set fileInfo to (get info for ((docLoc & i as string) as alias))
if (get size of fileInfo) is equal to fileSize then
tell application "Adobe InDesign CS5.5"
set myDoc to open (docLoc & i as string) without showing window
export myDoc format InDesign markup to ((newLoc as string) & (fName as string) & ".idml") without showing options
close myDoc saving no
end tell
tell application "Finder" to move ((docLoc & i as string) as alias) to ("SpamTrap HD:Backsave:converted:0ld Indd files (deleted automagically after a day)" as alias)
end if
end repeat
on error errmsg number errnum
do shell script "logger Backsaver - " & errnum & errmsg
end try
end if

return 2
end idle

Edited by S0ULphIRE - 8/19/11 at 12:14am
Blitzkrieg
(14 items)
 
  
CPUMotherboardGraphicsRAM
i7 980X Asus P6X58D Premium GTX 680 G.Skill 6Gb 2000Mhz 
Hard DriveOptical DriveCoolingOS
OCZ Vertex 3 BD/DVD Combo EK Supreme HF Windows 7 
MonitorKeyboardPowerCase
SAMSUNG S27A850T 27" Microsoft basic 600 :p AeroCool V12 1000W HAF 932 
Mouse
Razer Deathadder V2 
  hide details  
Reply
Blitzkrieg
(14 items)
 
  
CPUMotherboardGraphicsRAM
i7 980X Asus P6X58D Premium GTX 680 G.Skill 6Gb 2000Mhz 
Hard DriveOptical DriveCoolingOS
OCZ Vertex 3 BD/DVD Combo EK Supreme HF Windows 7 
MonitorKeyboardPowerCase
SAMSUNG S27A850T 27" Microsoft basic 600 :p AeroCool V12 1000W HAF 932 
Mouse
Razer Deathadder V2 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › Indesign CS5.5/CS5 backsave script