Environment is cygwin on Windows Server 2003 as I could not think how I would achieve this using Windows tools.
What I want ot achieve is the following.
I have a Directory D:\Data which contains further subfolders and files. I need to move "files" older than 6 months modification time to E:\Archive\ using the same folder structure.
As you can see there are files under various sub directories. So on the destination I need a way to create the same folder structure for the files older that 6 months to be placed in the same structure like so (assumes the documents anotherfile.doc and olderthan6mths.txt are older that 6 months):
So far I have been able to do this to make the directories but this makes all the directories:
And to locate the files older than 6 months, but this would obviusly just move all files into the root of /cygdrive/e/Archive/.
So how would I go about creating the directory structure in /cygdrive/e/Archive/ and moving files older than 6 months from /cygdrive/d/data/ whilst preserving there position in the directory structure destination starting at /cygdrive/e/Archive/ from /cygdrive/d/data/?
I have looked and googled by frankly my command line fu is not that good.... yet
So how would I go about creating the directory structure in /cygdrive/e/Archive/ and moving files older than 6 months from /cygdrive/d/data/ whilst preserving there position in the directory structure destination starting at /cygdrive/e/Archive/ from /cygdrive/d/data/?
I have looked and googled by frankly my command line fu is not that good.... yet
Not sure but.....
I don't believe there's any way to do matching/substitution on {} so I believe what you really need to do is have xargs invoke some script that you write, rather than calling mv, and have your script do the actual mv. That way, you can make substitutions in the path for where you want to move the file to. And, for the directory structure, I would use "mkdir -p" to create the hierarchy. In fact, you could just call it before each move. You only have to give it the path to the final directory and, if necessary, it will create all intermediate sub-directories. If it already exists, then it does nothing.
I had to make some slight changes to " FOLDER=$( basedir $SOURCE )" to fix it a little but this is what will work. I haven't tested yet with Spaces in the Directory or filenames yet (it is Windows After all) but at least I have a framework to go from now, Awesome!! Thanks to you both for your help so far, i'm very happy with my first post on the forums
I have to list the files of particular directory using file filter like find -name abc* something and if multiple file exist I also want time of each file up to seconds.
Currently we are getting time up to minutes in AIX is there any way I can get file last modification time up to seconds. (4 Replies)
Hi everyone,
I'd like to know if is there a way to list files but ignoring some according to their modification time (or creation, access time, etc.) with the command 'ls' alone.
I know the option -I exist, but it seems to only looking in the file name..
Thank you in advance for the... (8 Replies)
Hi All,
I need to list the files based modification time of the files from a directory, I cannot use "ls -t" as there are lot of files, which "ls" command cannot handle. New files will land there daily. So iam looking for an alternative through "find"command.
All suggestions are welcomed.
... (6 Replies)
Hi all,
I need the modification time of a file on a particular day say 3 days before.
I just don't want the last modification time. I need all the modification times on a particualar day.
Is there anyway to do it? Kindly help. Could anyone tell me where the modification time is stored?... (1 Reply)
Hi All,
I have two files (given below) each exists under different paths. I want to compare the modification time stamp of file1.txt is lessthan the modification time of file2.txt.
month1=`ls -l file1.txt | awk '{ print $6}'`
date1=`ls -file1.txt | awk '{ print $7}'`
time1=`ls... (1 Reply)
Hi All,
I would like to know the file modification time till seconds in Unix. So I tried ls -e and it worked fine. This Solaris 5.10
-rw-rw-r-- 1 test admin 22 Sep 12 11:01:37 2008 test_message
But I am not able to run the same command in SOlaris 5.6 and also in AIX/HP
Is there... (3 Replies)
How can I get and display the last modification time of a file? in scripting or specifically using Batch file
I want this info for me to determine whether an image has been edited or not by using the last modification time and compare it to our stored date of modification.
can somebody help... (5 Replies)
Does anyone know how to display the time with seconds
of when a file was last modified. I can get hour & minutes but
would also like seconds. --Running AIX (1 Reply)