Forum: Ruby Moving photos from a media card

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Greg _. (Guest)
on 2007-06-20 09:31
Trying to move and rename photos from a media card using OS X.

I get this error:
Errno::EXDEV: Cross-device link -
/Volumes/CANON_DC/DCIM/100CANON/IMG_2324.JPG or /Volumes/Knobby Aperture
Disk/Photos-digital/ Photographs/_Download folder/Latest
Download/2007.01.11-2324.gs-c.jpg

basic command is:
File.rename(File.join(dirPhotoCard, fileName), File.join(downloadFolder,
newFileName))

Works fine if I chang the dirPhotoCard to a folder on my Mac

I basically following Pine's Renamimg your photos script. I went back
and tried his script and I got the same results. Worked with Mac to Mac,
but not media card to Mac.

I tried a different type of card (Compact Flash instead of SD and got
the same results).

Thanks for any suggestions
Axel E. (Guest)
on 2007-06-20 13:45
(Received via mailing list)
This issue has already been discussed on this list:

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/...

If you still can't copy files, you may not have sufficient
reading/writing privileges for the device or it might not be
mounted ..

Best regards,

Axel
Greg _. (Guest)
on 2007-06-20 21:15
Axel E. wrote:
> This issue has already been discussed on this list:
>
> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/...
>

Axel

Thanks, that got me to a solution. I found a related discussion at

http://www.ruby-forum.com/topic/78627#128289

I went with since it breaks the operation down into more understand
steps, and it works:

require 'fileutils'
include FileUtils
cp(old, new ) # copy(old,new) works too if you like me don't talk UNIX
rm (old) #  remove(old)

There seems to be some confusion about how Ruby handles moving (mv)
files. Moving files is supposed to work with rename, but apparently
breaks down when the new and old directories are not in the same
partition. But the cp and rm steps are clearer than renaming and moving
(copying and deleting) in one step which is what I'm trying to do. (In
other words, it's not obvious from the name that "rename" renames and
moves.
This topic is locked and can not be replied to.