Problem Need to move files from a list of directories, rename them. Solution Use a for .. do .. done loop inside the for .. do .. done loop. And using basname and dirname. Credit to Ric Anderson, Steve 'SunMan', Michael Hocke. Ric Anderson gets points for going above and beyond, providing a working example. Which was appreciated. for D in `cat ${DIRECTORY_LIST}` do #find ${D} -type f -maxdepth 1 \! -newer ${TIMER} -print -exec mv -v "{}" ${DESTINATION} \; for file in `find ${D} -type f -maxdepth 1 \! -newer ${TIMER} -print `; do echo file=${file} target=`basename ${file}` dir=`dirname ${file}` parent=`basename ${dir}` echo dir=${dir}, target=${target}, parent=${parent} echo would mv ${file} ${parent}-${target}-${NOW} done done Bill Fiore I have had troubles with this part.... -exec mv -v "{}" as the braces dont alwayz give the desired result...depending on your shell and some other stuff especially if ya use {}'s more than once so now i do find /directory -options "filename wildcard" -exec foo {} where foo is an executable sh script e.g. #! /bin/sh mv $1 $1/date-time-stamp dont forget to chmod foo as executable Hugh Sasse > I think I've been "nerd sniped" Haw! http://xkcd.com/356/ I know I have been. "Hey, Brian, we have this problem ..." It's like throwing steak at my dog. > I think -prune should do that (with a bit of fiddling) -prune is to avoid sub-directories? I can assume there are no sub-directories. Something to keep in mind, however. > touch should allow you to create a file with a timestamp of whenever. Yes. I needed 'fifteen minutes before current time'. I couldn't make that work in shell, so 'borrowed' an example from the web. > I wonder if this is a DOS attack waiting to happen though? > Would it make sense to xz the files when storing them? In this particular case, probably not, and no. Not a potential DOS ... * This is not a public FTP server. * The number of actual files won't increase, just where we are putting them after the vendors upload them. * All 'ftp'd files are deleted when seven days old. We're quite clear to the end users this is not file storage, but file transfer. And if I archive the files the - in this case - EDI tool that downloads them won't know what to do with them. Thanks to all for the assist. ~brian Brian Dunbar Systems Administrator Plexus Corporation Desk: (920) 751-3364 Cell: (920) 716-2027 email: brian.dunbar@plexus.com _______________________________________________ sunmanagers mailing list sunmanagers@sunmanagers.org http://www.sunmanagers.org/mailman/listinfo/sunmanagersReceived on Thu Mar 29 13:32:36 2012
This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:44:19 EST