hello
I'm trying to batch copy files from one location to another. My script get's the output of a find command (i.e. find /disk3/jpm/seq -type f | xargs copy2boss)
The script works fine, except when filenames contains whitespace, backslashes and so on. Any hints? Is there another more accurate approach?
I need to copy files from user's seq directory to the boss's seq folder. The destination folder depends on the source folder.
Example copy
/disk3/user1/seq/tah/file1
to
/disk3/boss/seq/tah/file1
Here's the copy2boss script (sorry for the tcsh :o)
@ loop = 0
while ( $loop < $# )
@ loop ++
set current_file = $argv[$loop]
set target = (`echo $current_file | sed 's:\(\/disk3\/\).*\(\/seq\/\):\1boss\2:'`)
set target_dir = (`echo $target | sed 's|\(.*/\).*|\1|'`)
if ( ! -d $target_dir ) then
mkdir $target_dir
chown boss:user $target_dir
endif
if ( ! -r $target ) then
cp -p $current_file $target
chown boss:user $target
endif
end