هل هناك طريقة للحصول على نفس الوظيفة مثل أمر unix ln -s
في Mac OS X Finder (OS 10.5)؟ أريد أن أكون قادرًا على إنشاء روابط رمزية أثناء العمل في نوافذ Finder دون فتح الجهاز الطرفي.
لاحظ أن الأمر Make Alias
في Finder ليس هو ما أريد لأن هذه الأسماء المستعارة لا يمكن تصفحها في الجهاز الطرفي (لكن الروابط التي تم إنشاؤها باستخدام ln -s
يمكن تصفحها بواسطة كل من Terminal و Finder).
ماذا عن ذلك إنشاء روابط رمزية في الباحث عن طريق AppleScript ؟
إليك النص الأكثر صلة في هذا الرابط:
on run
open {choose file with Prompt "Choose a file to create a symbolic link:" without invisibles}
end run
on open the_files
repeat with i from 1 to (count the_files)
try
set posix_path to POSIX path of (item i of the_files)
if posix_path ends with "/" then set posix_path to text 1 thru -2 of posix_path
do Shell script "ln -s " & quoted form of posix_path & " " & quoted form of (posix_path & ".sym")
end try
end repeat
end open
ما عليك سوى لصقها في محرر AppleScript وحفظه كتطبيق . بعد ذلك ، يمكنك سحبها على شريط أدوات Finder أو ربطها في قفص الاتهام .
سيفعل SymbolicLinker ما تبحث عنه بالضبط وهو مجاني.
أجاب applescript على الرابط المقدم من المستخدم nuc أجاب على سؤالي. هنا هو applescript مستنسخة في حالة اختفاء هذا الرابط.
فضلت النص الذي قدمه المعلق jonn8n ، والذي تم استنساخه أيضًا باسم مقالة Macworld .
on run
open {choose file with Prompt ¬
"Choose a file to create a symbolic link:" without invisibles}
end run
on open the_files
repeat with i from 1 to (count the_files)
try
set posix_path to POSIX path of (item i of the_files)
if posix_path ends with "/" then set posix_path to ¬
text 1 thru -2 of posix_path
do Shell script "ln -s " & quoted form of posix_path ¬
& " " & quoted form of (posix_path & ".sym")
end try
end repeat
end open
قمت بحفظ هذا كتطبيق باستخدام Script Editor وسحبت التطبيق إلى الشريط الجانبي Finder حتى يمكنني الآن إنشاء ارتباطات رمزية بسحب الملفات أو المجلدات إلى أيقونة التطبيق.
يضيف Path Finder هذا إلى Finder ، ويضيف الكثير من الميزات.
أيضًا ، في Snow Leopard حيث لا يعمل SymbolicLinker ، يمكنك إنشاء خدمة مع Automator للقيام إما بالأمر Terminal أو AppleScript لإنشاء رابط رمزي.
أكثر واحد AS:
tell application "Finder"
repeat with f in (get selection)
set p to POSIX path of (f as text)
set p2 to POSIX path of (desktop as text) & name of f
do Shell script "ln -s " & quoted form of p & " " & quoted form of p2
end repeat
end tell
هناك تحسن محتمل في هذا البرنامج النصي هو تغيير معالج التشغيل لاستخدام الملفات المحددة حاليًا من Finder ، على النحو التالي:
on run
tell application "Finder" to set sel to selection
open sel
end run
on open the_files
repeat with i from 1 to (count the_files)
try
set posix_path to POSIX path of (item i of the_files as alias)
if posix_path ends with "/" then set posix_path to ¬
text 1 thru -2 of posix_path
try
do Shell script "ln -s " & quoted form of posix_path ¬
& " " & quoted form of (posix_path & ".sym")
on error
try
do Shell script "ln -s " & quoted form of posix_path ¬
& " " & quoted form of (posix_path & ".sym") with administrator privileges
end try
end try
end try
end repeat
end open
يمكنك أيضًا تعديل [application] /Contents/Info.plist لإضافته
<key>LSUIElement</key>
<true/>
فقط قبل الماضي </dict>. هذا يعني أن التطبيق سيتم تشغيله في الخلفية ، ولن يأتي إلى المقدمة عند النقر فوقه.