[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.2

simple applescript string issue

Asked by cntmedia in AppleScript

Tags: applescript

This script works great.

But I would like to hard code in the following strings:

=====================
sSearch  

and

sReplace
=====================

I am not in a position to learn new code languages, so I figure this is a simple syntax issue.

The code asks for a pop up box currently:

// Snippet from the attached code //

      

    set sSearch to text returned of
     (display dialog "Enter the beginning of the path to be replaced:
(e.g. Macintosh HD:FolderName:)" default answer "")

      set sReplace to text returned of
    (display dialog "Edit this path to match how it should be edited for Items in the catalog:" default answer sSearch)


// End Snippet //

I just want to hard code sSearch to:

this exact string
----------------------------

C:\Documents and Settings\cntmedia\My Documents\cntmedia_library\Source\

----------------------------

And sReplace to the exact string:
----------------------------

/Volumes/300gig/cntmedia_library/Source/

----------------------------


Thanks!

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
(*  Change Path Script for Portfolio 8.5  *)
 
 
-- Check to make sure Portfolio is running 
tell application "Finder" to set P_app to every process whose name contains "Portfolio"
if P_app is {} then
	display dialog ¬
		"Portfolio must be running for this script to operate." buttons {"OK"} default button {"OK"}
	return
end if
 
tell application "Portfolio"
	-- Check to make sure a catalog is opened 
	tell application "Portfolio" to set windowCount to count every document
	if not (exists of document 1) then
		display dialog ¬
			"A Portfolio catalog must be opened for this script to operate." buttons {"OK"} default button {"OK"}
		return
	end if
	
	--Get the appropriate search information from the user
	set sSearch to text returned of (display dialog "Enter the beginning of the path to be replaced:
(e.g. Macintosh HD:FolderName:)" default answer "")
	set sReplace to text returned of (display dialog "Edit this path to match how it should be edited for Items in the catalog:" default answer sSearch)
	if name of selected gallery of the front document ` name of gallery 1 of the front document then
		set cButton to button returned of (display dialog "Edit items in the current gallery, or the whole catalog? " buttons {"Entire Catalog", "Current Gallery"} default button 1)
	else
		set cButton to "Entire Catalog"
	end if
	
	-- pad the strings with ":" at the end
	(*
	if the last character of sSearch ` ":" then set sSearch to sSearch & ":"
	if the last character of sReplace ` ":" then set sReplace to sReplace & ":"
	*)
	set searchLength to length of sSearch
	set replaceLength to length of sReplace
	
	-- go to the proper gallery
	if cButton = "Entire Catalog" then
		tell the front document to display gallery 1
	end if
	set currentGallery to name of selected gallery of the front document
	set recordCount to count every record of gallery currentGallery of the front document
	
	set myIndex to 1
	set replaceCount to 0
	tell gallery currentGallery of the front document
		repeat recordCount times
			if file path of record myIndex starts with sSearch then
				tell record myIndex
					set thePath to file path as Unicode text
					set recordLength to the length of thePath
					set file path to sReplace & characters (searchLength + 1) through (recordLength) of thePath
					set replaceCount to replaceCount + 1
				end tell
			end if
			set myIndex to myIndex + 1
		end repeat
	end tell
	
	-- If no items were found, tell the user and then quit.
	if replaceCount is 0 then
		display dialog ¬
			"No Item Paths were found to match the Path entered. 
			
Be sure you are entering the beginning of the path you want to edit (e.g. Macintosh HD:FolderName), not an item within the path  (e.g. FolderName)." with icon 2 buttons {"OK"} default button {"OK"}
		return
	else
		display dialog ¬
			"Script completed. " & replaceCount & " items edited. " & "
 
Items found with a matching file path have been edited." buttons {"OK"} default button {"OK"}
		
	end if
end tell
[+][-]11/11/08 09:06 PM, ID: 22936954Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: AppleScript
Tags: applescript
Sign Up Now!
Solution Provided By: aherps
Participating Experts: 1
Solution Grade: A
 
[+][-]11/10/08 06:20 PM, ID: 22927413Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/11/08 05:27 PM, ID: 22936142Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_2_20070628