[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: command to mv files & folders to dir



>>>>> Mark Panen <mark.panen@gmail.com> writes:
>>>>> On Sat, Sep 24, 2011 at 11:53 AM, Ivan Shmakov wrote:
>>>>> Mark Panen <mark.panen@gmail.com> writes:

 >>> Made a bit off a muck up off things when i backed up parts of my
 >>> /home/mark directory to /mnt/deer

 >>> In /mnt/deer i know have hundreds of files and folders which i
 >>> rsynced on 22/09/2011.

 >>> I need a command line option to put them all In one shot in
 >>> /mnt/deer/zebra.

 >> It's not what I'd usually call “one shot” (= atomic), but, IIUC,
 >> the following single command line should do it:

 >> $ mkdir -pv -- /mnt/deer/zebra \
 >>       && find /mnt/deer/ -maxdepth 1 -mindepth 1 -not -name zebra \
 >>              -exec mv --target-directory=/mnt/deer/zebra -- {} +

 > will this mv only the file/folders created on the 22/09/2011, i want
 > the older files etc to stay behind.

	Somehow, I didn't understood that as part of the task.

	The -ctime constraint to find(1) may be helpful here, like:

$ mkdir -pv -- /mnt/deer/zebra \
      && find /mnt/deer/ \
             -maxdepth 1 -mindepth 1 -ctime -3 -not -name zebra \
             -exec mv --target-directory=/mnt/deer/zebra -- {} + 

	However, note that the Unix' “change time” is /not/ the file
	creation time (I know of no Unix filesystem to track the
	latter), but they /should/ coincide in this particular case.

	Note also that if the filesystem under /mnt is not a Unix one
	(such as VFAT), it should be checked whether the ctime is
	actually set as desired.  Like:

$ LC_ALL=C stat -- /mnt/deer/foobar 

	(Where foobar is one of the files copied 2011-09-22.)  Check if
	the Change: field is set to 2011-09-22.

-- 
FSF associate member #7257	Join news:comp.unix.shell for pretty
much /everything/ related to the POSIX Shell language and its variants.


Reply to: