1
A
回答
1
tell application "Finder"
set l to files of desktop as alias list
end tell
repeat with f in l
set input to read f as «class utf8»
set text item delimiters to "search"
set ti to text items of input
set text item delimiters to "replace"
set b to open for access f with write permission
set eof b to 0
write (ti as text) to b as «class utf8»
close access b
end repeat
我大多隻是用在項目中查找在TextMate中或Ruby腳本是這樣的:
Dir["#{ENV['HOME']}/Desktop/*"].each do |f|
input = File.read(f).gsub(/search/, "replace")
File.open(f, "w") { |f| f.print(input) }
end
您還可以使用SED:
sed -i '' 's/search/replace/g' ~/Desktop/*
相關問題
- 1. AppleScript中的文本文檔中的Applescript查找和替換工作表
- 2. 查找並替換文件夾中的多個文本文件
- 3. 查找和文本文件替換
- 4. 查找和替換文本
- 5. AppleScript查找和替換選定文件中的字符串集
- 6. 檢查和替換文件夾和子文件夾中的文本
- 7. AppleScript替換文件
- 8. 查找和替換文件
- 9. 在SSH中查找並替換文件或文件夾名稱
- 10. Perl的查找和替換側隙在文本文件中
- 11. 在.sql文件中查找和替換文本
- 12. 查找和替換c中的文本#
- 13. 替換文本文件中,使用AppleScript和sed
- 14. windows蝙蝠腳本查找替換文件夾和子文件夾中的每個文件
- 15. 如何查找和替換java中的pdf文件的文本
- 16. 使用sed來查找和替換smb.conf文件中的文本
- 17. 如何查找和替換文本文件中的一行?
- 18. 如何查找和替換文本文件中的用C#
- 19. 在Keynote中查找/替換爲AppleScript
- 20. 在Linux中查找並替換文本
- 21. 在WebPage中查找/替換文本Asp.Net
- 22. 在excel中查找並替換文本
- 23. 在python中查找並替換文本
- 24. 在文件夾和子文件夾中查找文件
- 25. 查找文件中的特定文本並替換該文件
- 26. 如何查找和替換文本?
- 27. PDFBox 2.0 RC3 - 查找和替換文本
- 28. Java的查找和替換文本
- 29. 用PHPWord查找和替換文本
- 30. jQuery的查找和替換文本