javaguy Posted October 14, 2007 Report Share Posted October 14, 2007 (edited) I'd like to write a script that will automatically transfer files from my mobile phone using obex and convert them to a friendly format, but I'm not sure how to refer to anything bluetooth-ish in my script. In the kde window my phone's video directory looks like obex://[00:xx:xx:xx:xx:xx]:7/SdVideos (hardware address changed to protect the innocent), but if I type ls obex:/[00:xx:xx:xx:xx:xx]:7/SdVideos bash doesn't like it. Anybody know how I'd do this? Edited October 15, 2007 by javaguy Quote Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted October 15, 2007 Report Share Posted October 15, 2007 Two things: [1] You didn't mask your HW Addr the second time you typed it. ;) [2] I don't have a bluetooth adapter to say for sure, but my thumb drive shows up as media:/hd/ in Konq, but in reality, it is /media/hd. Have you tried /obex/00:xx:xx:xx:xx:xx]:7/SdVideos or obex:/[00:xx:xx:xx:xx:xx]:7/SdVideos? In the second instance, notice :/ instead of :// Quote Link to comment Share on other sites More sharing options...
michaelcole Posted October 15, 2007 Report Share Posted October 15, 2007 If you have the Bluetooth services installed in KDE you can go the icon right click. select configure services Add new job you want photo copy change the name. Select it to run for only your phone. configure it for your phone mine a nokia N70 is TARGETFOLDER='/home/michael/Documents/Photos' # This is the folder on your mobile that contains the files. # Example: SOURCEFOLDER = '/Galerie' SOURCEFOLDER='/E:/Images' # The prefix for renamed files # Example: TARGETFILEPREFIX = 'Image' # Target files will have the name Image2004-04-17_12:00:00.<extenstion> then. TARGETFILEPREFIX='' # A file can have different types of timestamps. This option # defines which option to use to get the correct timestamp of # a file. See kioclient --help for the available options. # For some devices, --mtime might be the right one, for others # it's --ctime. You have to try it. # Example: TIMESTAMP_OPTION = '--ctime' TIMESTAMP_OPTION='--mtime' # --- END OF CONFIGURATION SECTION --- case "$1" in run) export TARGETFOLDER export SOURCEFOLDER export TARGETFILEPREFIX export TIMESTAMP_OPTION $JOB_TEMPLATE_DIR/Photo_Copy.real $@ ;; } And your done, every time you modify a file in that directory on the phone it will copy it to your computer.. Cool .. Quote Link to comment Share on other sites More sharing options...
javaguy Posted October 15, 2007 Author Report Share Posted October 15, 2007 Awesome. Thanks! You didn't mask your HW Addr the second time you typed it. Doh! Fixed, and thanks again. Quote Link to comment Share on other sites More sharing options...
scarecrow Posted October 15, 2007 Report Share Posted October 15, 2007 Notice that the "obex:/" is absolutely specific to the KDE Virtual Filesystem, and so your script will not work if run outside the KDE desktop! Quote Link to comment Share on other sites More sharing options...
javaguy Posted October 15, 2007 Author Report Share Posted October 15, 2007 That makes sense, since I'm using the KDE bluetooth thingy. BTW, the services script referenced above uses, under the hood, something called kfmclient, which is sort of the command-line Konqueror and does not appear to have a man page but does have a fairly thorough --help and also some good tutorials online. Quote Link to comment Share on other sites More sharing options...
javaguy Posted October 16, 2007 Author Report Share Posted October 16, 2007 Okay, I'm almost there! It kinda sorta works. I made my source directory /SdPictures, which is the memory card on my phone. When I click Execute This Job Now it copies...one file. When I click it again it copies...another copy of the same file with a new name (it puts a timestamp in the file name, very cool). There are lots of other files in /SdPictures on the phone, but it only gets one. I'd like it to copy all the pictures that are there. Also, there's a little checkbox next to my discovery job--what's the significance of this? I kinda suspect that if it's checked it gets run automagically at regular intervals, but I can't find any documentation on it. If that's the case I'll be leaving it unchecked, since I want to run it manually. And your done, every time you modify a file in that directory on the phone it will copy it to your computer.. I'm not sure that's the behavior. Does it check the timestamps? Quote Link to comment Share on other sites More sharing options...
michaelcole Posted October 16, 2007 Report Share Posted October 16, 2007 Check the --ctime may work better for you, Once it has a file it should not get it again. # For some devices, --mtime might be the right one, for others # it's --ctime. You have to try it. # Example: TIMESTAMP_OPTION = '--ctime' TIMESTAMP_OPTION='--mtime' The Check box is to set it to run automatically. Mine runs when i get in range of the bluetooth it detects my phone and copies the new images off the phone. I have it also set to only look for my phone for that job. At home i have two jos One for the wife and one for me. So at all times it checks the phones. Maybe better to set the min time between jobs as you walk around the house you dont want it to keep checking every five minutes, Flattens battery more quickly. And you can set it to run at a special time like when your sleeping and the phone is charging, Makes sure you have all the files you have updated. It should get all the files in one go, not sure why it is only getting one, it may think it already has the other files. due to the timestamps. Quote Link to comment Share on other sites More sharing options...
javaguy Posted October 16, 2007 Author Report Share Posted October 16, 2007 Got it! I ended up copying the underlying Photo_Copy.real from the templates directory into a new Photo_Copy.new in my scripts directory. I didn't like the way it was changing the file names (I like the file names my phone assigns to the photos), so I changed copyFile(addr, filename, newFilename) to copyFile(addr, filename, filename) and as it turns out, that solved the problem. And yes, it now works the way you said it would, gets me only the pictures I don't already have. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.