source: de.wigbels.ruby/mob2archiv/m2a.rb@ dc12dfc

Last change on this file since dc12dfc was 9ea979a, checked in by njw <njw@…>, 15 years ago

added author info

  • Property mode set to 100755
File size: 1.6 KB
Line 
1#!/usr/local/bin/ruby -w
2
3# Norbert Wigbels
4#
5#######################################################################
6# A little script that copies imagefiles from your
7# Sony Ericsson K700i mobilephone to <destination>
8#######################################################################
9#
10#
11
12def usage
13 puts "usage: m2a.rb <destination>"
14 exit(-1)
15end
16
17usage if ARGV.length != 1
18$destination = ARGV[0]
19
20# SE K700i organizes the camera pictures in Bilder/camera_semc
21BD_ADDR = "trebroN"
22OBEX_DIR1 = "Bilder"
23OBEX_DIR2 = "camera_semc"
24
25
26def doCrudeObexAppComm
27 begin
28 cam = getObexIOObject
29 cam.puts "ls"
30 cam.close_write
31 lines = cam.readlines
32 cam = getObexIOObject
33 lines.each do |line|
34 line =~ /Bild\(\d+\).jpg/
35 #black-magic-ruby $& holds the match
36 if !$&.nil?
37 cam.puts "get"
38 cam.puts $&
39 cam.puts $destination+'/'+$&
40 puts "copy picture "+$&+" to to "+$destination
41 #delete picturea after copying? uncomment...
42 #doesn't work on my phone:(
43 #cam.puts "delete"
44 #cam.puts $&
45 end
46 end
47 rescue Exception => ex
48 puts(ex.to_s)
49 ensure
50 # TODO: ensure connection is closed
51 cam.puts "disconnect"
52 cam.close
53 end
54end
55
56def getObexIOObject
57 cam = IO.popen("obexapp -a #{BD_ADDR} -C OPUSH", "w+")
58 cam.puts "cd #{OBEX_DIR1}"
59 cam.puts "cd #{OBEX_DIR2}"
60 return cam
61end
62
63# start here
64doCrudeObexAppComm
Note: See TracBrowser for help on using the repository browser.