Move files based on year


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Move files based on year
# 1  
Old 07-10-2008
Move files based on year

Hi All,

I have a directory which has crores of files since from 2003. I want to move ony the 2003 files to another directory. Please help
# 2  
Old 07-10-2008
I want to move only the 2003 files among 2004, 2005 files in the directory.
Thanks
# 3  
Old 07-10-2008
I help people that show they are trying...
So
1)you want to move files (dated 2003 ) in another directory
Q:
what commands do you think you will need?

Do a man of the commands...

2) How do I select those files?
start by listing correctly all the files so you can sort them by date...
use a pipe to filter with e.g. grep (man grep)

Show us you can do that and not the rest and someone will help you continue...
# 4  
Old 07-10-2008
Hammer & Screwdriver Here is a command you can investigate:

If you try the following -
Code:
> stat -c "%y|%n" * | grep "^2008-07-02"
2008-07-02 14:17:28.450802000 -0700|LinB.run.070208
2008-07-02 14:17:05.212540000 -0700|ctl
2008-07-02 04:19:34.049129000 -0700|data

It is retrieving files that were modified on 2008-07-02.
Each line is in the format of: time-info|filename

Play with this and see where it leads you.
# 5  
Old 07-10-2008
I'd use find. Look at the man page.
# 6  
Old 07-10-2008
I would agree, but then it depends on if all the concerned files are in the same directory at the same level or if there are some under sub-directories... (and we dont know... so your solution so far is the way to go...)
# 7  
Old 07-10-2008
You could do something like
find . ! -path . -prune -a -type f -newer etc...

Do you know of a more elegant way to prune the search? I find this one a little sloppy.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Move files with a certain suffix based on how many files are in another folder

Hello, First time poster. I am looking for a way to script or program the process of moving files from one folder to another, automatically, based on the count of files in the destination folder. I was thinking a shell script would work, but am open to the suggestions of the experts... (6 Replies)
Discussion started by: comtech
6 Replies

2. Shell Programming and Scripting

Move files based on status

Hi UNIX Experts, Kindly help me in this requirement where i want to move files based on its status. For Eg: I have 3 dir's --FileBox Dir this directory will have all the files which i need to process (in informatica ETL Tool) --Succeeded Dir this directory will have files which... (4 Replies)
Discussion started by: kumarinfa
4 Replies

3. Shell Programming and Scripting

Help in Logic - How to move files based on a condition

Hi All, I have 2 LINUX scripts (Lets say ScriptA & ScriptB) which copies files (lets say 'date_abc.txt , it goes to a while loop & checks for the files between 2 date varialbles) to directory X. (as Shown Below) These 2 scripts are called from 2 different Autosys schedules & runs at the... (3 Replies)
Discussion started by: dsfreddie
3 Replies

4. Shell Programming and Scripting

Move files to another directory based on name

Hi Folks, I have different type of file in my current directory. From my current directory i need to move the file which is start with csp_rules and if the file is having the string payg , then I need to move all this files to another directory /output/record. Please help me how to do this? ... (3 Replies)
Discussion started by: suresh01_apk
3 Replies

5. Shell Programming and Scripting

Need script to move files based on name

Hi folks, I'm new here and appreciate greatly any help. I have a bunch of files that need be moved and renamed. Fortunately, they are all in sequence... Present filename and path: /.catalog1/t76038_842-01 Move to: /.catalog1/76038-01 So, we need to drop the... (8 Replies)
Discussion started by: axslinger
8 Replies

6. Shell Programming and Scripting

Move files based on date in filename

I know this gets covered quite a bit in the forum and I think there is enough there for me to figure out how to do what I am trying to do, I just don't think I would do it very efficiently so I am going to ask the question... I have database log files with date and time stamps in the file like ... (7 Replies)
Discussion started by: slatoms
7 Replies

7. Red Hat

Move files of a certain year to other directory

Hi all, I have a massive amount of recording files in .WAV format stored in a directory, files dating back to 2006. It is a huge amount of files as Linux cannot even do a listing of it all, it states: "argument list too long" What I would like to do is the following: Find all the files of... (6 Replies)
Discussion started by: codenjanod
6 Replies

8. Shell Programming and Scripting

Move files based on year of creation

Hi All, I have a directory which has crores of files since from 2003 till now. I want to move only the 2003 files to another directory. Please help. Thanks (2 Replies)
Discussion started by: IHK
2 Replies

9. UNIX for Dummies Questions & Answers

Move files based on year

I have a directory which has crores of files since from 2003. I want to move only the 2003 files to another directory. Please help in doing this. Thanks (1 Reply)
Discussion started by: IHK
1 Replies

10. UNIX for Dummies Questions & Answers

how to move files into different folders based on filename

I need to move a bunch of files into folders that have the same name. I wanted to either do this with some filter command or some type of batch file that I could save that would already include all of the mv commands since I will have to do this process often. Whatever method you think is easier. ... (7 Replies)
Discussion started by: italia5
7 Replies
Login or Register to Ask a Question