I've run into what feels like a pretty basic error, but I can't find any documentation about what I'm struggling with. Here's the code:
require "fileutils"
def new_name(fn, dest = '/Volumes/External/Different\ Sublevel/Renamed', append = '_01')
ext = File.extname(fn)
File.join( dest, File.basename(fn, ext) + append + ext )
end
Dir[ '/Volumes/External/Example/Sublevels/**/*.xml' ].
select { |fn| File.file? fn }.
each { |fn| FileUtils.cp fn, new_name(fn) }
All I'm trying to do is move some files (non-destructively) and append the filename. It works great on some local files, but I did multiple levels of ../../../
to get it to work. Is there something special about specifying external drives?