I´m putting togheter the final touches on a script, which processes all subfolders from one input folder I choose by prompt.
My question is:
I would like to just copy folder aliases into the input folder before I start the process, but how do I make Finder/PS sort out the path to the actual folders. This is probably simple and I´ve searched around for it, but haven´t manage to find a good solution.
I´ve tried with different stuff like: “list folder”, “as folders”, “alias” but don´t quite get the grip of it.
Here is a little bit of my script:
set inputFolder to choose folder
tell application "Finder"
set the getinputFolder to list folder inputFolder without invisibles
set folderList to folders in getinputFolder
end tell
repeat with aFolder in folderList
--------------Actions
end repeat
Any tip would be appreciated
Tnx:)
Model: PB
AppleScript: 1.9.3
Browser: Safari 312
Operating System: Mac OS X (10.3.9)
set inputFolder to choose folder
try
tell application "Finder" to set folderList to folders of inputFolder
on error
set folderList to {}
end try
if folderList = {} then
beep
display dialog "No subfolders found in chosen folder." buttons {"Cancel"} default button 1 with icon 0
end if
repeat with aFolder in folderList
--------------Actions
end repeat
Jon
Model: PowerBook 1.25MHz
AppleScript: 1.10
Browser: Safari 412
Operating System: Mac OS X (10.4)
But it don´t solve my problem, because my sub folders are just aliases to the actual folders, this to keep the original folders at they´re original locations, wherever that might be.
I seem to remember seeing this somewhere, but when I need it it´s gone, you know the drill.
The frase “resolve alias” keeps popping up, but I can´t seem to make it fit in or work.
To explain my folder flow see this figure: http://www.upi.no/images/graf_1005.jpg
Here you see that the folders “1, 2, 3” resides within 3 different folders,
but I have made alias of them inside the input folder.
Hope this makes more sense to what I´m after.
Once again thank you for any tip
Cheers
Chris:)
Model: PB
AppleScript: 1.9.3
Browser: Safari 312
Operating System: Mac OS X (10.3.9)
Sorry, I didn’t see the alias file requirements. Yes, guardian is on the right track. This is what I would use:
set inputFolder to choose folder
tell application "Finder"
try
set folderList to folders of inputFolder
on error
set folderList to {}
end try
try
set aliasList to alias files of inputFolder
repeat with i from 1 to (count aliasList)
set originalItem to (aliasList's item i)'s original item
if (originalItem as Unicode text) ends with ":" then set end of folderList to originalItem
end repeat
end try
end tell
if folderList = {} then
beep
display dialog "No subfolders found in chosen folder." buttons {"Cancel"} default button 1 with icon 0
end if
repeat with aFolder in folderList
--------------Actions
end repeat
Jon
Model: PowerBook 1.25MHz
AppleScript: 1.10
Browser: Safari 412
Operating System: Mac OS X (10.4)
I lost the versions of your script that you sent me when the site changed design (all the PM’s were deleted, this is where your script was living!)
Could you please resend them to me??
I dont know if you have got my previouse messages, (from experiance the emails from the bbs.applescript website have ended up in my hotmail junkmail folder!) If you have Im sorry to hassel you but your script was so close to what I wanted to do, and I was learning so much!
I lost the versions of your script that you sent me when the site changed design (all the PM’s were deleted, this is where your script was living!)
Could you please resend them to me??
I dont know if you have got my previouse messages, (from experiance the emails from the bbs.applescript website have ended up in my hotmail junkmail folder!) If you have Im sorry to hassel you but your script was so close to what I wanted to do, and I was learning so much!
--This AS is made by Christopher Wiedswang, cristo@online.no. It´s put together with bits and pieces found around...
set deliMiter to AppleScript's text item delimiters
property dialog_timeout : 30 -- set the amount of time before dialogs auto-answer.
set alert_message to "Select folder to process:"
display dialog the alert_message buttons {"Cancel", "OK"} default button 2 with icon 1 giving up after dialog_timeout
set inputFolder to choose folder
set alert_message to "Select folder to save processed folders in:"
display dialog the alert_message buttons {"Cancel", "OK"} default button 2 with icon 1 giving up after dialog_timeout
set outputFolder to choose folder
tell application "Finder"
set folderList to folders in inputFolder
end tell
repeat with aFolder in folderList
set AppleScript's text item delimiters to ""
set toThis to aFolder as string
if the toThis ends with ":" then
set the toThru to ((the number of characters of the toThis) - 1)
set toThis to (characters 1 thru toThru of toThis) as string
end if
if the toThis contains ":" then
set AppleScript's text item delimiters to {":"}
set toThis to get last text item of toThis
set AppleScript's text item delimiters to deliMiter
end if
tell application "Finder"
set filesList to files in aFolder
if (not (exists folder ((outputFolder as string) & toThis))) then
set suboutputFolder to make new folder at outputFolder with properties {name:toThis}
else
set outputFolder to folder ((outputFolder as string) & toThis)
end if
end tell
tell application "Adobe Photoshop CS"
set display dialogs to never
close every document saving yes
end tell
repeat with aFile in filesList
tell application "Finder"
-- The step below is important because the 'aFile' reference as returned by
-- Finder associates the file with Finder and not Photoshop. By converting
-- the reference below 'as alias', the reference used by 'open' will be
-- correctly handled by Photoshop rather than Finder.
set theFile to aFile as alias
set theFileName to name of theFile
end tell
tell application "Adobe Photoshop CS"
set startRulerUnits to ruler units of settings
set ruler units of settings to pixel units
open theFile
set docRef to current document
--Her goes your actions, you have to change "imageSizeB" and "Applescript" with your action name("imageSizeB") and from folder set("Applescript")
do action "imageSizeB" from "Applescript"
-- Convert the document to a document mode that supports saving as jpeg
if (bits per channel of docRef is sixteen) then
set bits per channel of docRef to eight
end if
set docName to name of docRef
set docBaseName to getBaseName(docName) of me
set newFileName to (suboutputFolder as string) & docBaseName
-- This is the saving properties, which saves as JPEG, quality 12
set myOptionsJPG to ¬
{class:JPEG save options, embed color profile:true, format options:standard, matte:none, quality:12}
save docRef in file newFileName as JPEG with options myOptionsJPG appending lowercase extension with copying
close current document without saving
end tell
end repeat
end repeat
set the date_stamp to ((the current date) as string)
set alert_message to "The job is done at " & date_stamp & ", I´m waiting for more..." as Unicode text
display dialog the alert_message buttons {"Show me", "No thanks"} default button 2 with icon 1 giving up after dialog_timeout
set the user_choice to the button returned of the result
if user_choice is "Show me" then
tell application "Finder"
--go to the desktop
activate
--open the folder
open outputFolder
end tell
end if
-- Returns the document name without extension (if present)
on getBaseName(fName)
set baseName to fName
repeat with idx from 1 to (length of fName)
if (item idx of fName = ".") then
set baseName to (items 1 thru (idx - 1) of fName) as string
exit repeat
end if
end repeat
return baseName
end getBaseName
Enjoy,
Chris
Model: PB 1GHz
AppleScript: 1.9.3
Browser: Safari 312
Operating System: Mac OS X (10.3.9)