Estoy tratando de encontrar una manera de mover automáticamente (sin intervención del usuario) un archivo de A a B, sustituyendo a B si existe, idealmente poniendo la copia existente de B en la carpeta de la Papelera correspondiente.
Esto se hará en un shell script. Eventualmente A y B tendrán que ser $VARIABLES
así:
/usr/bin/osascript <<EOT
tell application "Finder"
move POSIX file "$SOURCE" to POSIX file “$DEST" with replacing
end tell
EOT
pero Ni siquiera puedo conseguir que esto funcione sin variables, como esta:
/usr/bin/osascript <<EOT
tell application "Finder"
move POSIX file "/Users/luomat/Desktop/1.txt" to POSIX file "/Users/luomat/Desktop/2.txt" with replacing
end tell
EOT
Tomé esa sintaxis casi directamente de Stackoverflow 14058061 pero obtengo este resultado:
24:132: execution error: Finder got an error: AppleEvent handler failed. (-10000)
También me encontré con un artículo de MacTech que sugería el uso de replacing true
así que lo intenté:
/usr/bin/osascript <<EOT
tell application "Finder"
move POSIX file "/Users/luomat/Desktop/1.txt" to POSIX file "/Users/luomat/Desktop/2.txt" replacing true
end tell
EOT
pero sigue diciendo:
24:132: execution error: Finder got an error: AppleEvent handler failed. (-10000)
Tenga en cuenta que stackoverflow #12708195 No estoy tratando de incitar al usuario a hacer esto, pero idealmente me gustaría que ocurriera "automáticamente" como dicen los niños.
Entonces ¿qué estoy haciendo mal y/o me falta? Intentando buscar información en Google sobre el código de error (-10000) me dice más o menos que significa "AppleScript falló", lo cual no es muy útil.