On Sep 28, 2007, at 2:42 PM, Gabriel Dragffy wrote:
> On 28 Sep 2007, at 14:17, Rob Biedenharn wrote:
>>>
>>> Hi Rob
>>>
>>> Thanks for your help.
>>>
>>> What I am trying to achieve is replace the slashes (/) in file/ 
>>> directory names under a certain directory. So, for example, I  
>>> want to recursively rename offending files that are under / 
>>> Volumes, but I don't want them moved from their current  
>>> directory... just renamed. What's the best way to go about that?
>>>
>>> Regards
>>>
>>> Gabe
>>
>> This doesn't make sense.  There aren't slashes in the name, those  
>> are separating directories along the path to the file.
>>
>> /Volumes/Macintosh HD/Users/rab/code/ruby/quiz/081-Hash to  
>> OpenStruct/another.yml
>> /Volumes/Macintosh HD/Users/rab/code/ruby/quiz/081-Hash to  
>> OpenStruct/hash2ostruct.rb
>> /Volumes/Macintosh HD/Users/rab/code/ruby/quiz/081-Hash to  
>> OpenStruct/openstruct.yml
>> /Volumes/Macintosh HD/Users/rab/code/ruby/quiz/081-Hash to  
>> OpenStruct/recursive.yml
>>
>> These files have some directories containing spaces in the name,  
>> but the name of each file is just the last part (another.yml,  
>> hash2ostruct.rb, openstruct.yml, recursive.yml).  If I go to my  
>> home directory and rename 'code' to be 'source', I haven't changed  
>> the names of the files, but I *have* changed the path needed to  
>> reach them.
>>
>> If you really *do* have files with '/' in their names, chances are  
>> you need to use a low-level utility to recover from that mess.  If  
>> you're just seeing in the Mac OS X Finder that there are "slashes"  
>> in the name of a file, perhaps you're seeing an artifact of the  
>> Mac's filesystem.  If you open a Terminal, you'll see that there  
>> the file has a ':' in the place that Finder shows you '/'.
>>
>> Perhaps you can find these files (like I said, see if you find  
>> them properly before to operate on them) with Ruby like this:
>> 	ruby -e 'puts Dir["**/*:*"]'
>> But know that there are a great many files that *NEED* to contain  
>> ':' created by iChat, AddressBook, Safari, and others.  (You might  
>> not want to mess with anything under a Library directory ;-)
>
>
> Rob, you are spot on! When I view the files in Finder they have  
> slashes in the name. However, I need to backup these files to a  
> linux files server using Rsync (because rsync won't copy everything  
> but only the changes) but it keeps conking out with errors. If I  
> run cp -rv  it fails with errors like:
> cp: /Volumes/Cecil/02photography/1997_past/::PANORMANIA: Invalid  
> argument
> When I look at the file in Finder it has a name with slashes in it.  
> My immediate thought was to automatically rename all files like  
> this. What would suggest I do?
>
> Best regards
>
> Gabriel

I think that you are running into trouble with rsync's use of a : or  
two for special syntax to identify a file on a different host.

rsync(1)                                                               
rsync(1)

NAME
        rsync - faster, flexible replacement for rcp

SYNOPSIS
        rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST

        rsync [OPTION]... [USER@]HOST:SRC DEST

        rsync [OPTION]... SRC [SRC]... DEST

        rsync [OPTION]... [USER@]HOST::SRC [DEST]

        rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST

        rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]

        rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST

You may have to quote the file name of supply an explicit host  
portion even if it matches the default.  You might alternatively  
create an incremental tar archive of the changes and then back up the  
tar file to the linux box.  (...and either way it's not really a Ruby  
problem.)

-Rob

Rob Biedenharn		http://agileconsultingllc.com
Rob / AgileConsultingLLC.com