Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Save file groups in TextWrangler' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Save file groups in TextWrangler
Authored by: stevenstromer on Sep 03, '08 02:13:40PM

Unfortunately, I am trying to work on a large number of files on a server whose password contains an @ symbol (I know this isn't the best idea, but I'm not in a position to change it.). When attempting to retrieve the files via SFTP, this causes an error, as it is not encoded properly within the script's code at this point:

if hasFTP then
set ps to text returned of (display dialog "Type your password of the server your files are on" default answer "")
end if
if length of allfiles is greater than 0 then
set afile to item 1 of allfiles
set afile to my snr(afile, ":@", (":" & ps & "@"))
open location afile
end if
set allfiles to rest of allfiles
repeat with afile in allfiles
set afile to my snr(afile, ":@", (":" & ps & "@"))
open location afile
end repeat

Can anyone tell me how to encode/escape(?) the characters in the password properly, as held in the variable 'ps' so that the @ symbol will not cause a problem? I'm just not too familiar with AppleScript! It would be a GREAT help.

Thanks!



[ Reply to This | # ]
Save file groups in TextWrangler
Authored by: stevenstromer on Sep 04, '08 11:34:48AM

Solved my own problem. I removed the code querying the user for a password, returning responsibility for querying to the operating system. Revised script 'Open Bookmark Collection.scpt' is as follows:

tell application "TextWrangler"
set filename to (choose file)
open filename opening in new_window
set allfilesstr to text of text document 1
close text document 1
set allfiles to rest of my splitit(allfilesstr, "||")

if length of allfiles is greater than 0 then
set afile to item 1 of allfiles
open location afile
end if
set allfiles to rest of allfiles
repeat with afile in allfiles
open location afile
end repeat
end tell

on splitit(the_string, search_string)
tell (a reference to my text item delimiters)
set {old_tid, contents} to {contents, search_string}
set {arr, contents} to {the_string's text items, old_tid}
end tell
return arr
end splitit

Thanks again to the original script writer. You have made my life worlds easier!



[ Reply to This | # ]