Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 48 lines (36 sloc) 1.26 KB
# code by Albert Zeyer, 2012-06-04
# code under zlib licence
# more:
import sys, os
files = sys.argv[1:]
debug = False
if not files:
print >>sys.stderr, "usage:", sys.argv[0], "<files>"
for f in files:
if not os.path.exists(f):
print >>sys.stderr, "file", repr(f), "does not exists"
# script around FSPathMoveObjectToTrashSync
import ctypes
CoreServices = ctypes.CDLL("/System/Library/Frameworks/CoreServices.framework/CoreServices")
#OSStatus FSPathMoveObjectToTrashSync (
# const char *sourcePath,
# char **targetPath,
# OptionBits options
OSStatus = ctypes.c_int32 # MacTypes.h
OptionBits = ctypes.c_uint32 # MacTypes.h
rm = CoreServices.FSPathMoveObjectToTrashSync
rm.argtypes = (ctypes.c_char_p, ctypes.POINTER(ctypes.c_char_p), OptionBits)
rm.restype = OSStatus
for f in files:
trashfn = ctypes.c_char_p()
res = rm(f, ctypes.pointer(trashfn), 0)
if debug:
print "rm", repr(f), "->", res, repr(trashfn.value) if trashfn else "NULL"
if res != 0:
print >>sys.stderr, "error", res, "on file", repr(f)
Something went wrong with that request. Please try again.