如何使用applescript将桌面元素(图标,文件,文件夹)始终保存在同一位置

迪克5

使用脚本,我们将创建另一个脚本,该脚本将存储桌面上所有元素的位置,所创建的脚本将被编译并可用于将所有先前受保护的元素放回原处。

/adesktopsave/deskico.txt这是将用于编译的临时文件。/adesktopsave/savedicoposition.scpt是保存的脚本,被编译为与applescrit一起使用

此处使用的所有名称仅用于示例。这些名称没有特定的属性。

仅需要计划使用此脚本之前创建一个文件夹。它是:/ adesktopsave

另外,“ try”之后的行尾(\ n)也“ end try”和&“}”)

尊重是非常重要的,这样文本才可以使用。

    tell application "Finder" to set theList to {name, desktop position} of items of desktop 
try 
do shell script "rm -f /adesktopsave/deskico.txt"

do shell script "echo tell application " & quoted form of (quote & "Finder" & quote) & return & " >>/adesktopsave/deskico.txt" 

end try 

set n to (count (first item of theList))


repeat with i from 1 to n       

set inp to do shell script "echo " & quoted form of (item i of first item of theList)       

set xy to (item i of second item of theList)    

set AppleScript's text item delimiters to ","   

set xyz to do shell script "echo " & xy     
set wxyz to ("{" & xyz & "}
 ")         

set ligne to "try 
" & "set desktop position of item " & quoted form of (quote & inp & quote) & " of desktop to " & quoted form of (wxyz) & "end try 
"       
set ligne to do shell script "echo " & ligne & " >>/adesktopsave/deskico.txt"    

end repeat 

do shell script "echo " & "end tell" & return & " >>/adesktopsave/deskico.txt"

    display dialog "Do you want to save your icons in their current location?" buttons {"Cancel", "Save"} default button 2 with title "Save  the positions of icons"

    if (button returned of result) is "Cancel" then     
set n to do shell script "echo " & n 
else    
do shell script "osacompile -o " & "/adesktopsave/savedicoposition.scpt" & " /adesktopsave/deskico.txt" 
end if 

return n
迪克5

我们可以将脚本简化为最简单的表达方式。可能会有错误的风险。

set ligne to ""
do shell script "mkdir -p  /adesktopsave"
tell application "Finder" to set {names, positions} to {name, desktop position} of items of the desktop
set ligne to "tell application \"Finder\"
"
set n to (count names)
set AppleScript's text item delimiters to ","
repeat with i from 1 to n
set ligne to ligne & ("try
" & "set desktop position of item " & (quote & item i of names & quote) & "  to  {" & item i of positions & "}
end try
")
end repeat
set ligne to ligne & ("end tell" & return)
display dialog "Do you want to save your icons in their current location?" buttons {"Cancel", "Save"} default button 2 with title "Save the positions of icons"
  if (button returned of result) is "Cancel" then 
    set n to do shell script "echo " & n
else
  do shell script "osacompile -o " & "/adesktopsave/savedicoposition.scpt  -e  "  & quoted form of ligne
end if
set AppleScript's text item delimiters to ""
tell application "Finder" to open POSIX file "/adesktopsave/savedicoposition.scpt"
return n

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

在同一位置如何有两个相同的文件夹?

来自分类Dev

使用批处理文件将zip文件夹从一个位置移动到另一位置

来自分类Dev

如何将svn文件夹从一个位置移动到另一位置

来自分类Dev

组项目:无法将文件安装到同一位置

来自分类Dev

如何在bash脚本中将一个文件夹中的所有tif文件转换为pdf并保存到另一位置而不循环通过?

来自分类Dev

如何使用CSS在同一位置显示2个元素?

来自分类Dev

使用Pandas从固定宽度的文件中读取数据不在同一位置

来自分类Dev

如何使div始终漂浮在同一位置?

来自分类Dev

如何使div始终漂浮在同一位置?

来自分类Dev

使用CSS在同一位置显示2个图标?

来自分类Dev

调整浏览器大小时,如何将每个元素固定在同一位置?

来自分类Dev

即使我重新加载页面,如何将 div 元素放在同一位置并检索 .data() 值

来自分类Dev

批处理文件中的计数器进行循环-如何将数字保持在同一位置?

来自分类Dev

批处理文件中的计数器进行循环-如何将数字保持在同一位置?

来自分类Dev

如何使用Python将多个图保存在一个文件夹中?

来自分类Dev

将鼠标悬停在同一位置的两个元素上

来自分类Dev

将所有元素放在同一位置

来自分类Dev

如何将文件从磁盘上的一个位置移动到另一位置?

来自分类Dev

将多个图像放置在同一位置

来自分类Dev

CSS 如何让表格中的所有元素在同一位置结束

来自分类Dev

从同一位置的批处理文件中执行.msi

来自分类Dev

业力在同一位置覆盖文件和测试

来自分类Dev

请确保文件“ kernel-ranchu”与系统映像位于同一位置

来自分类Dev

如何使按钮保持在同一位置?

来自分类Dev

如何保持文字在同一位置?

来自分类Dev

如何使用SSIS将xls文件转换为xlsx文件并保存在文件夹中?

来自分类Dev

使用jQuery在同一位置显示项目

来自分类Dev

桌面文件夹位置

来自分类Dev

如何使用AppleScript在桌面上的文件夹中创建新文件?

Related 相关文章

  1. 1

    在同一位置如何有两个相同的文件夹?

  2. 2

    使用批处理文件将zip文件夹从一个位置移动到另一位置

  3. 3

    如何将svn文件夹从一个位置移动到另一位置

  4. 4

    组项目:无法将文件安装到同一位置

  5. 5

    如何在bash脚本中将一个文件夹中的所有tif文件转换为pdf并保存到另一位置而不循环通过?

  6. 6

    如何使用CSS在同一位置显示2个元素?

  7. 7

    使用Pandas从固定宽度的文件中读取数据不在同一位置

  8. 8

    如何使div始终漂浮在同一位置?

  9. 9

    如何使div始终漂浮在同一位置?

  10. 10

    使用CSS在同一位置显示2个图标?

  11. 11

    调整浏览器大小时,如何将每个元素固定在同一位置?

  12. 12

    即使我重新加载页面,如何将 div 元素放在同一位置并检索 .data() 值

  13. 13

    批处理文件中的计数器进行循环-如何将数字保持在同一位置?

  14. 14

    批处理文件中的计数器进行循环-如何将数字保持在同一位置?

  15. 15

    如何使用Python将多个图保存在一个文件夹中?

  16. 16

    将鼠标悬停在同一位置的两个元素上

  17. 17

    将所有元素放在同一位置

  18. 18

    如何将文件从磁盘上的一个位置移动到另一位置?

  19. 19

    将多个图像放置在同一位置

  20. 20

    CSS 如何让表格中的所有元素在同一位置结束

  21. 21

    从同一位置的批处理文件中执行.msi

  22. 22

    业力在同一位置覆盖文件和测试

  23. 23

    请确保文件“ kernel-ranchu”与系统映像位于同一位置

  24. 24

    如何使按钮保持在同一位置?

  25. 25

    如何保持文字在同一位置?

  26. 26

    如何使用SSIS将xls文件转换为xlsx文件并保存在文件夹中?

  27. 27

    使用jQuery在同一位置显示项目

  28. 28

    桌面文件夹位置

  29. 29

    如何使用AppleScript在桌面上的文件夹中创建新文件?

热门标签

归档