Recent Posts

Pages: 1 2 3 4 [5] 6 7 8 9 10
41
Scripting in general / Renaming and Filing Images
« Last post by mbornbach on November 04, 2015, 02:01:11 PM »
I have an applescript droplet that renames and files images.  When I drop the images onto this droplet, it will rename the first one and then give me an error -4960, stopping the script before it files even one image. If I try dropping images onto the droplet a second time after they've been renamed and caused an error, the script then cooperates and files the images. If I do the renaming and filing script as two separate droplets instead of one, it works perfectly. I'm assuming I have something wrong that is preventing the renaming and filing parts of the script from working together. It may be one of those obvious things that I just can't see, but I'd really appreciate it if someone could help me see why it's not working.


Code: [Select]
on open droppedfiles
   
    repeat with afile in droppedfiles

     
            --USING THE FINDER TO RENAME THE FILE, ADDING  _s_4c to THE IMAGE NAME
            tell application "Finder"
                activate
                set fileToMove to afile
                set fileToMove_Name to name of fileToMove
                set fileExt to name extension of fileToMove
               
                set oldDelims to AppleScript's text item delimiters
               
                try
                    --ELIMINATING _4c on IMAGES THAT ALREADY HAD _4c IN FILE NAME BEFORE PROCESSING
                    if name of fileToMove contains "_4c" and name of fileToMove does not contain "_s_4c" then
                        set AppleScript's text item delimiters to {"_4c"}
                       
                        --ELIMINATING DOUBLE _s_4c on IMAGES THAT ALREADY HAD _s_4c IN FILE NAME BEFORE PROCESSING
                    else if name of fileToMove contains "_s_4c" then
                        set AppleScript's text item delimiters to {"_s_4c"}
                       
                        --FOR IMAGES THAT DIDN'T HAVE _s_4c IN FILE NAME BEFORE PROCESSING
                    else if name of fileToMove does not contain "_s_4c" or "_4c" then
                        set AppleScript's text item delimiters to {"."}
                    end if
                   
                    set fileName to name of fileToMove --> ex. Disneyland.tif
                    set nameWithoutExtension to first text item of fileName --> Disneyland
                    set newName to nameWithoutExtension & "_s_4c" & "." & fileExt --> Disneyland_s_4c.tif
                    set name of fileToMove to newName
                   
                    --RESETTING APPLESCRIPT'S TEXT ITEM DELIMITERS AND NAME
                    set AppleScript's text item delimiters to oldDelims
                    set name of fileToMove to fileToMove_Name
                   
                    --TELLING FINDER TO RESET APPLESCRIPT'S TEXT ITEM DELIMITERS IF THERE'S AN ERROR
                on error
                    set AppleScript's text item delimiters to oldDelims
                   
                end try
            end tell
           
            --FILING THE IMAGES
            tell application "Finder"
                activate
               
                set fileToMove to afile
                set fileToMove_Name to name of fileToMove as string
                set fileExt to name extension of fileToMove as string
               
                --DUPLICATE FILE TO WEB CONVERT FOLDER ON R DRIVE
                try
                    if fileExt is "tif" then
                        duplicate fileToMove to alias "Volumes:sdrive:IMAGES_FROM PREPRESS:z_DEBORAH_CONVERT and FILE:"
                    else
                        move fileToMove to alias "Volumes:server1:Advertising Department:5_ADVERTISING DEPT - PREPRESS:1_ADV IMAGE PROCESSING:2_PROCESSING:Processing:Scripts:Convert:"
                    end if
                   
                    --Moving file to the "File Manually in RDRIVE & 1_4c IMAGES folder" inside the Processing Folder if there is an error
                on error
                    move fileToMove to alias "Volumes:server1:Advertising Department:5_ADVERTISING DEPT - PREPRESS:1_ADV IMAGE PROCESSING:2_PROCESSING:Processing:Scripts:File Manually in RDRIVE & 1_4c IMAGES:" with replacing
                end try
               
               
               
                --ONTO FILING INTO THE 1_4C IMAGES FOLDERS
                try
                   
                    --DECLARING LISTS OF STRINGS OF CHARACTERS FOR THE COMPUTER TO LOOK FOR
                   
                    --AG Files
                    set AG00string to {"AG00", "AG01", "AG02", "AG03"}
                    set AG04string to {"AG04", "AG05", "AG06", "AG07", "AG08", "AG09"}
                    set AGAstring to {"AGA", "AGB", "AGC", "AGD", "AGE", "AGF", "AGG", "AGH", "AGI", "AGJ", "AGK", "AGL", "AGM", "AGN", "AGO", "AGP", "AGQ", "AGR", "AGS", "AGT", "AGU", "AGV", "AGW", "AGX", "AGY", "AGZ"}
                    set AG_Astring to {"AG_A", "AG_B", "AG_C", "AG_D", "AG_E", "AG_F", "AG_G", "AG_H", "AG_I", "AG_J", "AG_K", "AG_L", "AG_M", "AG_N", "AG_O", "AG_P", "AG_Q", "AG_R", "AG_S", "AG_T", "AG_U", "AG_V", "AG_W", "AG_X", "AG_Y", "AG_Z"}
                   
                    --BI Files
                    set BI0string to {"BI0", "BI1", "BI2", "BI3", "BI4", "BI5"}
                    set BI6string to {"BI6"}
                    set BI7string to {"BI7"}
                    set BI8string to {"BI8"}
                    set BI9string to {"BI9"}
                    set BIAstring to {"BIA", "BIB", "BIC", "BID", "BIE", "BIF", "BIG", "BIH", "BII", "BIJ", "BIK", "BIL", "BIM", "BIN", "BIO", "BIP", "BIQ", "BIR", "BIS", "BIT", "BIU", "BIV", "BIW", "BIX", "BIY", "BIZ"}
                    set BI_Astring to {"BI_A", "BI_B", "BI_C", "BI_D", "BI_E", "BI_F", "BI_G", "BI_H", "BI_I", "BI_J", "BI_K", "BI_L", "BI_M", "BI_N", "BI_O", "BI_P", "BI_Q", "BI_R", "BI_S", "BI_T", "BI_U", "BI_V", "BI_W", "BI_X", "BI_Y", "BI_Z"}
                   
                                       
                    --MOVING THE ACTUAL FILES TO THE 1_4C IMAGES FOLDERS
                   
                    --Moving AG files to 1_4c IMAGES Folders
                    if AG00string contains (text 1 thru 4 of fileToMove_Name) then
                        move fileToMove to alias "Volumes:server1:Advertising Department:2_IMAGES - HIGH RES FOR PRINT:1_4c IMAGES:AG-high res images:AG00 - AG03 - HI RES:"
                    else if AG04string contains (text 1 thru 4 of fileToMove_Name) then
                        move fileToMove to alias "Volumes:server1:Advertising Department:2_IMAGES - HIGH RES FOR PRINT:1_4c IMAGES:AG-high res images:AG04 - AG09 - HI RES:"
                    else if AGAstring contains (text 1 thru 3 of fileToMove_Name) then
                        move fileToMove to alias "Volumes:server1:Advertising Department:2_IMAGES - HIGH RES FOR PRINT:1_4c IMAGES:AG-high res images:AGA - AGZ - HI RES:"
                    else if AG_Astring contains (text 1 thru 4 of fileToMove_Name) then
                        move fileToMove to alias "Volumes:server1:Advertising Department:2_IMAGES - HIGH RES FOR PRINT:1_4c IMAGES:AG-high res images:AGA - AGZ - HI RES:"
                       
                        --Moving BI files to 1_4c IMAGES Folders
                    else if BI0string contains (text 1 thru 3 of fileToMove_Name) then
                        move fileToMove to alias "Volumes:server1:Advertising Department:2_IMAGES - HIGH RES FOR PRINT:1_4c IMAGES:BI-high res images:BI0 - BI5 - HI RES:"
                    else if BI6string contains (text 1 thru 3 of fileToMove_Name) then
                        move fileToMove to alias "Volumes:server1:Advertising Department:2_IMAGES - HIGH RES FOR PRINT:1_4c IMAGES:BI-high res images:BI6 - HI RES:"
                    else if BI7string contains (text 1 thru 3 of fileToMove_Name) then
                        move fileToMove to alias "Volumes:server1:Advertising Department:2_IMAGES - HIGH RES FOR PRINT:1_4c IMAGES:BI-high res images:BI7 - HI RES:"
                    else if BI8string contains (text 1 thru 3 of fileToMove_Name) then
                        move fileToMove to alias "Volumes:server1:Advertising Department:2_IMAGES - HIGH RES FOR PRINT:1_4c IMAGES:BI-high res images:BI8 - HI RES:"
                    else if BI9string contains (text 1 thru 3 of fileToMove_Name) then
                        move fileToMove to alias "Volumes:server1:Advertising Department:2_IMAGES - HIGH RES FOR PRINT:1_4c IMAGES:BI-high res images:BI9 - HI RES:"
                    else if BIAstring contains (text 1 thru 3 of fileToMove_Name) then
                        move fileToMove to alias "Volumes:server1:Advertising Department:2_IMAGES - HIGH RES FOR PRINT:1_4c IMAGES:BI-high res images:BIA - BIZ - HI RES:"
                    else if BI_Astring contains (text 1 thru 4 of fileToMove_Name) then
                        move fileToMove to alias "Volumes:server1:Advertising Department:2_IMAGES - HIGH RES FOR PRINT:1_4c IMAGES:BI-high res images:BIA - BIZ - HI RES:"
                       
                        --Moving All Other Files to the "File Manually in 1_4c IMAGES" Folder inside the Processing Folder
                    else
                        move fileToMove to alias "Volumes:server1:Advertising Department:5_ADVERTISING DEPT - PREPRESS:1_ADV IMAGE PROCESSING:2_PROCESSING:Processing:Scripts:File Manually in 1_4c IMAGES:"
                    end if
                   
                    --Moving Files to the "File Manually in 1_4c IMAGES" Folder inside the Processing Folder if there is an error
                on error
                    move fileToMove to alias "Volumes:server1:Advertising Department:5_ADVERTISING DEPT - PREPRESS:1_ADV IMAGE PROCESSING:2_PROCESSING:Processing:Scripts:File Manually in 1_4c IMAGES:"
                end try
               
            end tell
    end repeat
end open

42
Hello, I am French !
Nobody's perfect!  ;D
Quote
I search an extension or script allowing me to split a multi-page file into multiple files of 1 page automatically. Whatever the number of page of the file to be cut.
For example, a 10-page file = 10 files of 1 page.
All these files have the same, with an increment from January to October following the name.
Even if the original file is facing page (front / back), files created would not be facing page (in single-sided) and no particular model (the models of elements from the file number on each page would page files created with an empty model.
Example name fichier.qxp ==> (several pages file)
example 01.qxp
example 02.qxp
example 03.qxp
... ..
example 10.qxp

Thank you and excuse my English!
I see you got an answer from Sirish on Quark's forums.
43
Hello, I am French !
I search an extension or script allowing me to split a multi-page file into multiple files of 1 page automatically. Whatever the number of page of the file to be cut.
For example, a 10-page file = 10 files of 1 page.
All these files have the same, with an increment from January to October following the name.
Even if the original file is facing page (front / back), files created would not be facing page (in single-sided) and no particular model (the models of elements from the file number on each page would page files created with an empty model.
Example name fichier.qxp ==> (several pages file)
example 01.qxp
example 02.qxp
example 03.qxp
... ..
example 10.qxp

Thank you and excuse my English!
44
Adobe InDesign scripting / Re: Moving IDML files into a subfolder
« Last post by mbornbach on June 12, 2015, 10:47:59 AM »
I was looking for something else and stumbled upon some code that gave me an idea. I have it working now with the following code:

Code: [Select]
on open of droppedfiles
tell application "Adobe InDesign CC 2014" to activate
repeat with afile in droppedfiles


--TELLING INDESIGN TO CREATE THE IDML FILE
tell application "Adobe InDesign CC 2014"
open afile
set doc_path to the file path of active document
set doc_name to get name of active document as string
set idml_name to text 1 thru -6 of doc_name
set idml_destination to (doc_path as string) & idml_name & ".idml"
tell active document
export format InDesign markup to idml_destination
close afile saving no
end tell
end tell

--CREATING IDML FOLDER IF IT DOESN'T EXIST YET
set parentFolder to my getParentFolder(afile)
set newFolder to (parentFolder as text) & ":"
set parentFolder_IDML to parentFolder & "IDML"
if not my CheckForFolder(parentFolder & "IDML:") then
tell application "Finder"
set subFolder to (make new folder at folder parentFolder with properties {name:"IDML"})
end tell
end if
end repeat


--MOVING IDML FILES INTO THE IDML FOLDER
tell application "Finder"
move (files of folder parentFolder whose name extension is "idml") to folder parentFolder_IDML with replacing
end tell
end open

--SOME FUNCTIONS FROM A FORUM THAT ARE NEEDED TO MAKE CREATING THE IDML FOLDER WORK
on getParentFolder(filePath)
set folderParts to my GetTextItem(filePath as text, ":", {1, -2})
set OldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set parentFolder to folderParts as text
set AppleScript's text item delimiters to OldDelims

return (parentFolder & ":") as text
end getParentFolder

on CheckForFolder(thisFolder)
tell application "Finder"
return (exists folder thisFolder)
end tell
end CheckForFolder

on GetTextItem(ThisString, ThisDelim, ThisItem)
-- ThisString -> String to look in
-- ThisDelim -> Text element that delimit the string
-- ThisItem -> Number of the element to return
copy the text item delimiters to OldDelims
set the text item delimiters to ThisDelim
set arrItem to every text item of ThisString


if class of ThisItem is list then
set FromItem to item 1 of ThisItem
set ToItem to item 2 of ThisItem
set TheReturn to (items FromItem thru ToItem of arrItem) as text
else
if ThisItem ≠ 0 then
set TheReturn to (item ThisItem of arrItem) as text
else
set TheReturn to arrItem -- return every items
end if
end if
set the text item delimiters to OldDelims
return TheReturn
end GetTextItem
45
Adobe Photoshop scripting / Free script for batch processing photoshop images
« Last post by mbornbach on June 11, 2015, 11:46:53 AM »
Here is a photoshop script I pieced together by doing a lot of google searches and reading the applescript dictionary. Feel free to use any part or all of it for your needs.

This script:
- Changes the color mode to cmyk
- Flattens the image
- Selects a path you've drawn with the pen tool and sets it to a clipping path with a flatness of 2 and a name of "path 1"
- Crops the image to 25 pixels outside of the clipping path
- Resizes the image to set the longest side to no more than 1550 pixels
- Adds the text "_s_4c" to the end of the filename
- Adds the text "_ERROR" to the end of the filename if there is an error in photoshop, so I will know I need to take a look at the file in photoshop (usually this happens if I forgot to draw the path with the pen tool)

Code: [Select]
on open droppedfile
tell application "Adobe Photoshop CC 2014"
set display dialogs to never
activate
repeat with afile in droppedfile
tell application "Adobe Photoshop CC 2014"
open afile showing dialogs never

--TELLING PHOTOSHOP TO USE PIXEL MEASUREMENTS AND SETTING THE TARGET IMAGE SIZE SO IT CAN RESIZE THE IMAGE LATER ON
set ruler units of settings to pixel units
set target_size to 1550

--DOING ALL THE PHOTOSHOP WORK
tell current document
try

--CHANGING TO CMYK
change mode to CMYK

--FLATTENING IMAGE
flatten

--SETTING NAME OF PATH AND TURNING IT INTO A CLIPPING PATH
select first path item
if name of first path item is not "Path 1" then set name of first path item to "Path 1"
make clipping path of first path item flatness 2

--CROPPING THE IMAGE
create selection first path item feather amount 0 with antialiasing
expand selection by 25
set theCropBounds to bounds of selection
crop bounds theCropBounds

--RESIZING THE IMAGE IF IT IS TOO BIG
set long_side to height
set long_side_identity to 1
if width > long_side then set long_side_identity to 2
if width > long_side then set long_side to width
if long_side > target_size as integer and long_side_identity = 1 then
resize image height target_size resample method bicubic
end if
if long_side > target_size as integer and long_side_identity = 2 then
resize image width target_size resample method bicubic
end if
close saving yes

on error
close afile

tell application "Finder"
activate
set theFile to afile
set oldDelims to AppleScript's text item delimiters

--ADDING _ERROR TO FILENAME FOR PROBLEM FILES
set AppleScript's text item delimiters to {"."}
set fileName to name of theFile --> ex. Disneyland.tif
set nameWithoutExtension to first text item of fileName --> Disneyland
set newName to nameWithoutExtension & "_ERROR" & ".tif" --> Disneyland_s_4c.tif
set name of theFile to newName

--RESETTING APPLESCRIPT'S TEXT ITEM DELIMITERS
set AppleScript's text item delimiters to oldDelims
end tell
end try
end tell


--DONE WITH PHOTOSHOP, NOW USING THE FINDER TO RENAME THE FILE, ADDING  _s_4c to THE IMAGE NAME
tell application "Finder"
activate
set theFile to afile
set oldDelims to AppleScript's text item delimiters

try
--FOR IMAGES THAT DIDN'T HAVE _s_4c IN FILE NAME BEFORE PROCESSING
if name of theFile does not contain "_s_4c" then
set AppleScript's text item delimiters to {"."}
set fileName to name of theFile --> ex. Disneyland.tif
set nameWithoutExtension to first text item of fileName --> Disneyland
set newName to nameWithoutExtension & "_s_4c" & ".tif" --> Disneyland_s_4c.tif
set name of theFile to newName

--ELIMINATING DOUBLE _s_4c on IMAGES THAT ALREADY HAD _s_4c IN FILE NAME BEFORE PROCESSING
else if name of theFile contains "_s_4c" then
set AppleScript's text item delimiters to {"_s_4c"}
set fileName to name of theFile --> ex. Disneyland.tif
set nameWithoutExtension to first text item of fileName --> Disneyland
set newName to nameWithoutExtension & "_s_4c" & ".tif" --> Disneyland_s_4c.tif
set name of theFile to newName
end if

--RESETTING APPLESCRIPT'S TEXT ITEM DELIMITERS
set AppleScript's text item delimiters to oldDelims

--TELLING FINDER TO RESET APPLESCRIPT'S TEXT ITEM DELIMITERS IF THERE'S AN ERROR
on error
set AppleScript's text item delimiters to oldDelims

end try

end tell
end tell
end repeat
end tell
end open



46
Quark XPress scripting / Re: Tweaking Script to Batch Process PDFs in Quark
« Last post by mbornbach on June 11, 2015, 10:49:29 AM »
Tweaked it some more:

Now it:
-Creates a pdf file of just the first 2 pages of each document dropped onto the applescript droplet
-Creates a new subfolder named "PDFs" within the folder that the quark files are in if that subfolder doesn't already exist
-Moves the pdf files into the "PDFs" subfolder, replacing any old pdf files in that folder with the same filename

Code: [Select]
on open of droppedfiles
tell application "QuarkXPress" to activate
repeat with afile in droppedfiles

--TELLING QUARK TO CREATE PDF FILES
tell application "QuarkXPress"
open afile
set my_destination to file path of document 1 as string
set doc_name to get (characters 1 thru -5) of my_destination as string
export document 1 in (doc_name & ".pdf") as "PDF" page range "1, 2" PDF output style "Quad PDF" --Change Quad PDF to name of your pdf output style
close document 1 saving no

--CREATING PDFs FOLDER IF IT DOESN'T EXIST YET
set parentFolder to my getParentFolder(afile)
set newFolder to (parentFolder as text) & ":"
if not my CheckForFolder(parentFolder & "PDFs:") then
tell application "Finder"
set subFolder to (make new folder at folder parentFolder with properties {name:"PDFs"})
end tell
end if
end tell
end repeat

--MOVING PDF FILES INTO THE PDFs FOLDER
tell application "Finder"
set subFolder to (folder "PDFs" of folder parentFolder)
move (files of folder parentFolder whose name extension is "pdf") to subFolder with replacing
end tell
end open

on getParentFolder(filePath)
set folderParts to my GetTextItem(filePath as text, ":", {1, -2})
set OldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set parentFolder to folderParts as text
set AppleScript's text item delimiters to OldDelims

return (parentFolder & ":") as text
end getParentFolder

on CheckForFolder(thisFolder)
tell application "Finder"
return (exists folder thisFolder)
end tell
end CheckForFolder

on GetTextItem(ThisString, ThisDelim, ThisItem)
-- ThisString -> String to look in
-- ThisDelim -> Text element that delimit the string
-- ThisItem -> Number of the element to return
copy the text item delimiters to OldDelims
set the text item delimiters to ThisDelim
set arrItem to every text item of ThisString


if class of ThisItem is list then
set FromItem to item 1 of ThisItem
set ToItem to item 2 of ThisItem
set TheReturn to (items FromItem thru ToItem of arrItem) as text
else
if ThisItem ≠ 0 then
set TheReturn to (item ThisItem of arrItem) as text
else
set TheReturn to arrItem -- return every items
end if
end if
set the text item delimiters to OldDelims
return TheReturn
end GetTextItem
47
Adobe InDesign scripting / Re: Moving IDML files into a subfolder
« Last post by mbornbach on June 11, 2015, 10:44:42 AM »
If it helps, this is the applescript I was referring to for creating pdfs from quark and moving them into a subfolder. This script works like it should.

Code: [Select]
on open of droppedfiles
tell application "QuarkXPress" to activate
repeat with afile in droppedfiles

--TELLING QUARK TO CREATE PDF FILES
tell application "QuarkXPress"
open afile
set my_destination to file path of document 1 as string
set doc_name to get (characters 1 thru -5) of my_destination as string
export document 1 in (doc_name & ".pdf") as "PDF" page range "1, 2" PDF output style "Quad PDF"
close document 1 saving no

--CREATING PDFs FOLDER IF IT DOESN'T EXIST YET
set parentFolder to my getParentFolder(afile)
set newFolder to (parentFolder as text) & ":"
if not my CheckForFolder(parentFolder & "PDFs:") then
tell application "Finder"
set subFolder to (make new folder at folder parentFolder with properties {name:"PDFs"})
end tell
end if
end tell
end repeat

--MOVING PDF FILES INTO THE PDFs FOLDER
tell application "Finder"
set subFolder to (folder "PDFs" of folder parentFolder)
move (files of folder parentFolder whose name extension is "pdf") to subFolder with replacing
end tell
end open

on getParentFolder(filePath)
set folderParts to my GetTextItem(filePath as text, ":", {1, -2})
set OldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set parentFolder to folderParts as text
set AppleScript's text item delimiters to OldDelims

return (parentFolder & ":") as text
end getParentFolder

on CheckForFolder(thisFolder)
tell application "Finder"
return (exists folder thisFolder)
end tell
end CheckForFolder

on GetTextItem(ThisString, ThisDelim, ThisItem)
-- ThisString -> String to look in
-- ThisDelim -> Text element that delimit the string
-- ThisItem -> Number of the element to return
copy the text item delimiters to OldDelims
set the text item delimiters to ThisDelim
set arrItem to every text item of ThisString


if class of ThisItem is list then
set FromItem to item 1 of ThisItem
set ToItem to item 2 of ThisItem
set TheReturn to (items FromItem thru ToItem of arrItem) as text
else
if ThisItem ≠ 0 then
set TheReturn to (item ThisItem of arrItem) as text
else
set TheReturn to arrItem -- return every items
end if
end if
set the text item delimiters to OldDelims
return TheReturn
end GetTextItem
48
Adobe InDesign scripting / Moving IDML files into a subfolder
« Last post by mbornbach on June 11, 2015, 10:10:27 AM »
Good morning. I have an applescript for InDesign CC that I'm working on. It creates an IDML file and moves it into a subfolder named IDML. It also creates the subfolder named IDML if that folder doesn't yet exist. I am getting an error whenever the finder tries to move the IDML files into the IDML subfolder only if that folder already exists.

I assume it has something to do with this line
Code: [Select]
set subFolder to (folder "IDML" of folder parentFolder)
because if I comment out that line and delete the IDML subfolder, it works perfectly.  (If I comment out that line and don't delete the IDML subfolder, then it doesn't run the section of code in the if block that sets the subfolder to make a new folder with properties {name:"IDML"}) and I get an error telling me the variable subFolder is not defined).

So, could someone enlighten me on how I could write it so that it does set the variable subfolder to the correct folder? The full code is below. The interesting thing is I have very similar code that I use to create pdf files from quark and move them into a subfolder and it works great. The part that tells the finder to create the folder and move the files is identical to what is in that script.

Code: [Select]
on open of droppedfiles
tell application "Adobe InDesign CC 2014" to activate
repeat with afile in droppedfiles


--TELLING INDESIGN TO CREATE THE IDML FILE
tell application "Adobe InDesign CC 2014"
open afile
set doc_path to the file path of active document
set doc_name to get name of active document as string
set idml_name to text 1 thru -6 of doc_name
set idml_destination to (doc_path as string) & idml_name & ".idml"
tell active document
export format InDesign markup to idml_destination
close afile saving no
end tell
end tell

--CREATING IDML FOLDER IF IT DOESN'T EXIST YET
set parentFolder to my getParentFolder(afile)
set newFolder to (parentFolder as text) & ":"
if not my CheckForFolder(parentFolder & "IDML:") then
tell application "Finder"
set subFolder to (make new folder at folder parentFolder with properties {name:"IDML"})
end tell
end if
end repeat


--MOVING IDML FILES INTO THE IDML FOLDER
tell application "Finder"
set subFolder to (folder "IDML" of folder parentFolder)
move (files of folder parentFolder whose name extension is "idml") to subFolder with replacing
end tell
end open

--SOME FUNCTIONS FROM A FORUM THAT ARE NEEDED TO MAKE CREATING THE IDML FOLDER WORK
on getParentFolder(filePath)
set folderParts to my GetTextItem(filePath as text, ":", {1, -2})
set OldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set parentFolder to folderParts as text
set AppleScript's text item delimiters to OldDelims

return (parentFolder & ":") as text
end getParentFolder

on CheckForFolder(thisFolder)
tell application "Finder"
return (exists folder thisFolder)
end tell
end CheckForFolder

on GetTextItem(ThisString, ThisDelim, ThisItem)
-- ThisString -> String to look in
-- ThisDelim -> Text element that delimit the string
-- ThisItem -> Number of the element to return
copy the text item delimiters to OldDelims
set the text item delimiters to ThisDelim
set arrItem to every text item of ThisString


if class of ThisItem is list then
set FromItem to item 1 of ThisItem
set ToItem to item 2 of ThisItem
set TheReturn to (items FromItem thru ToItem of arrItem) as text
else
if ThisItem ≠ 0 then
set TheReturn to (item ThisItem of arrItem) as text
else
set TheReturn to arrItem -- return every items
end if
end if
set the text item delimiters to OldDelims
return TheReturn
end GetTextItem

This is the error I get:
Quote
Can’t get «class cfol» "nas:Advertising Department:5_ADVERTISING DEPT - PREPRESS:3_Signs:7x33 Softlines Signs:InDesign Files:*Lifestyle :" of application "Finder".

Thanks!  :)
49
try this:

Code: [Select]
on open of theFiles
-- Executed when files are dropped on the script
repeat with thisFile in theFiles
set parentFolder to my getParentFolder(thisFile)
if not my CheckForFolder(parentFolder & "PDF Files:") then
tell application "Finder"
make new folder at folder parentFolder with properties {name:"PDF Files"}
end tell
end if
-- Do something with thisFile
end repeat
end open

on getParentFolder(filePath)
set folderParts to my GetTextItem(filePath as text, ":", {1, -2})
set OldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set parentFolder to folderParts as text
set AppleScript's text item delimiters to OldDelims

return (parentFolder & ":") as text
end getParentFolder

on CheckForFolder(thisFolder)
tell application "Finder"
return (exists folder thisFolder)
end tell
end CheckForFolder

on GetTextItem(ThisString, ThisDelim, ThisItem)
-- ThisString -> String to look in
-- ThisDelim -> Text element that delimit the string
-- ThisItem -> Number of the element to return
copy the text item delimiters to OldDelims
set the text item delimiters to ThisDelim
set arrItem to every text item of ThisString


if class of ThisItem is list then
set FromItem to item 1 of ThisItem
set ToItem to item 2 of ThisItem
set TheReturn to (items FromItem thru ToItem of arrItem) as text
else
if ThisItem ≠ 0 then
set TheReturn to (item ThisItem of arrItem) as text
else
set TheReturn to arrItem -- return every items
end if
end if
set the text item delimiters to OldDelims
return TheReturn
end GetTextItem
50
Are all the files coming from a single source? (Hum, I don't even know if it's possible to drop files from several sources actually, but one never knows).
Well, this said sth like this might help you at least to see what you get:
Code: [Select]
on open droppedfile
set the_list to {}
repeat with afile in droppedfile
set end of the_list to afile -- list of aliases
end repeat
set the_choice to (choose from list the_list)
end open
Next step is to separate folder path from file name. Sth like this might be helpful too:
Code: [Select]
set the_folder to choose folder with prompt "PLEASE CHOOSE A FOLDER."
set the_file to choose file with prompt "PLEASE CHOOSE A FILE."

set parent_folder_of_the_file to (do shell script "dirname " & (quoted form of POSIX path of the_file))
set name_of_the_file to (do shell script "basename " & (quoted form of POSIX path of the_file))

beep 1
display dialog ("CHOSEN FOLDER:" & return & the_folder as string) & return & return & "CHOSEN FILE CONTAINER:" & return & parent_folder_of_the_file & return & "CHOSEN FILE NAME:" & return & name_of_the_file

-- CREATING A FOLDER VIA SHELL SCRIPT
-- do shell script "mkdir -p " & (quoted form of POSIX path of the_folder) & "PDFfiles" -- SO HERE THE_FOLDER IS THE FOLDER YOU CHOSE FIRST
Pages: 1 2 3 4 [5] 6 7 8 9 10