如果我在本地或远程服务器上的finder中选择一个文件,我希望脚本将POSIX路径作为文本粘贴到剪贴板,以便在聊天窗口中粘贴等。
这是我到目前为止所做的,但不是很干净:
on run
tell application "Finder"
copy selection to theSelected
set outputPathList to {}
set anItem to theSelected
copy (POSIX path of (anItem as alias)) to end of outputPathList
set AppleScript's text item delimiters to return
set outputString to outputPathList as string
set AppleScript's text item delimiters to ""
set the clipboard to outputString
end tell
end run
关于如何清理它的任何想法?
答案 0 :(得分:1)
ArrayList<String> list = new ArrayList<>();
for (int i = 0; i < SpeakRecyclerGrid.recyclerView.getChildCount(); i++) {
list.add(((EditText) SpeakRecyclerGrid.recyclerView.getChildAt(i)).getText().toString());
}
Integer numOfWords = list.size();
words = list.toString();
Integer count = 0;
Integer startPoint = 0;
Integer scrollPos = 1;
Integer leftOver = 0;
ArrayList<String> arrayList = new ArrayList<>();
if (list.size() <= columns) {
if (words.contains(", 's")) {
formatString = words.replaceFirst(", 's", "'s");
speakWords(formatString);
System.out.println("formatString < 7"+formatString);
} else if (words.contains(", ing")) {
formatString = words.replaceFirst(", ing", "ing");
speakWords(formatString);
System.out.println("formatString < 7"+formatString);
} else {
speakWords(words);
System.out.println("words < 7"+words);
}
}
if (list.size()>=columns) {
for (int i = 0; i < words.length(); i++) {
if (words.charAt(i) == ',') {
count++;
if (count == columns) {
String ab = words.substring(startPoint, i + 1);
scrollPos++;
if (ab.contains(", 's")) {
formatString = ab.replaceFirst(", 's", "'s");
speakWords(formatString);
System.out.println("ab with s" + formatString);
} else if (ab.contains(", ing")) {
formatString = ab.replaceFirst(", ing", "ing");
speakWords(formatString);
System.out.println("ab with ing" + formatString);
} else {
speakWords(ab);
System.out.println("ab" + ab);
}
SpeakGrid.recyclerView.getLayoutManager().scrollToPosition(columns * scrollPos);
startPoint = i + 1;
count = 0;
leftOver = words.length() - startPoint;
System.out.println("scroll" + scrollPos + "startpoint" + startPoint +"leftover" + leftOver);
if (leftOver > 3) {
String ab2 = words.substring(startPoint, words.length());
if (ab2.contains(", 's")) {
formatString = ab2.replaceFirst(", 's", "'s");
speakWords(formatString);
System.out.println("ab2 with s" + formatString);
} else if (ab2.contains(", ing")) {
formatString = ab2.replaceFirst(", ing", "ing");
speakWords(formatString);
System.out.println("ab2 with ing" + formatString);
} else {
speakWords(ab2);
System.out.println("ab2" + ab2);
}
System.out.println("scroll" + scrollPos + "startpoint" + startPoint +"leftover" + leftOver);
count = 0;
}
}
}
}
}
答案 1 :(得分:0)
Finder的属性selection
返回Finder说明符列表
此脚本将所有POSIX路径(每行一个)复制到剪贴板。
tell application "Finder" to set theSelection to (get selection)
if theSelection is {} then return
set outputPathList to {}
repeat with anItem in theSelection
set end of outputPathList to POSIX path of (anItem as text)
end repeat
set {TID, text item delimiters} to {text item delimiters, return}
set the clipboard to outputPathList as text
set text item delimiters to TID