Move file older date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Move file older date
# 1  
Old 07-14-2011
Move file older date

hlow all
i have folder with name like this
Code:
20110512  
20110601  
20110602

so i want move the last 1 day to other directory for example this date 20110602 so i want move folder older 1 day from this date
20110512 -----> this folder will move to other dir
20110601-----> this folder will move to other dir
20110602--->this still here cause is current now

what shoud i do for this caseSmilie
# 2  
Old 07-15-2011
Quote:
Originally Posted by zvtral
hlow all
i have folder with name like this
Code:
20110512  
20110601  
20110602

so i want move the last 1 day to other directory for example this date 20110602 so i want move folder older 1 day from this date
20110512 -----> this folder will move to other dir
20110601-----> this folder will move to other dir
20110602--->this still here cause is current now

what shoud i do for this caseSmilie
What you need to move..? If its files then post few sample file-names to get an idea how your file looks like. If not please detail your objective.
# 3  
Old 07-15-2011
you can try something like below

prevdate=`date -d '1 day ago' +%Y%m%d`;

find <search_path> -name $prevdate -type d ! -newermt `date +%Y%m%d` -exec mv -f '{}' <destination_dir> \;

Last edited by Amaravathi; 07-15-2011 at 10:10 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to move files older than certain time?

If there are 100 files created in a directory /data/ today from 2:00 AM to 10:00 AM I need to move files older than 3:00 AM to a new directory /hold/ How to do that? Also, if I have to move files between 3:00 AM to 9:00 AM, how to achieve that (3 Replies)
Discussion started by: eskay
3 Replies

2. Shell Programming and Scripting

Move log files with date and delete older than 3 weeks

I have written a script which generate one logfile on every sunday and thursday I want to move the older log files into /tmp directory befor generating new one so i used mv command like mv usr/sbin/appl/logfile.txt usr/sbin/appl/tmp 2) But when i move this file to /tmp it will... (1 Reply)
Discussion started by: Nakul_sh
1 Replies

3. Shell Programming and Scripting

Delete log files content older than 30 days and append the lastest date log file date

To delete log files content older than 30 days and append the lastest date log file date in the respective logs I want to write a shell script that deletes all log files content older than 30 days and append the lastest log file date in the respective logs This is my script cd... (2 Replies)
Discussion started by: sreekumarhari
2 Replies

4. Shell Programming and Scripting

How to move the older than 30 file to another ftp server

Hi All I need to move the older than 30 days file to another ftp server. I have source structure like this Files folder Folder1 Folder2 Folder3 I need to create same Target structure and I need to move the older than 30 day file to another ftp server, can you please suggest me how I develop... (1 Reply)
Discussion started by: murari83.ds
1 Replies

5. Shell Programming and Scripting

Move File Every Last Date of the Month

Dear experts, I have a file named "GI_GR.csv" generated by SAP everyday. What I need is every last date of the month ( Jan 31, Feb 28/29, Mar 31, etc), the file is copied to subfolder named "archive" and rename it to "GI_GR_Jan.csv" for January and so on. What I want to ask is, how to check if... (8 Replies)
Discussion started by: kris.adrianto
8 Replies

6. Shell Programming and Scripting

removing rows from text file older than certain date

Hi I need a way of removing rows from a txt file that are older than 30 days from today, going by the date in column 2, below is an example from my file. I have tried awk but don't have enough knowledge. I would really appreciate some help. 41982,15/07/2010,H833AB/0,JZ,288... (6 Replies)
Discussion started by: firefox2k2
6 Replies

7. Shell Programming and Scripting

Move the latest or older File from one directory to another Directory

I Need help for one requirement, I want to move the latest/Older file in the folder to another file. File have the datetimestamp in postfix. Example: Source Directory : \a destination Directory : \a\b File1 : xy_MMDDYYYYHHMM.txt (xy_032120101456.txt) File2: xy_MMDDYYYYHHMM.txt... (1 Reply)
Discussion started by: pp_ayyanar
1 Replies

8. Shell Programming and Scripting

Delete files older than 3 months.(read date from the name of the file)

Guys, My log files stored in the date format format below(log_20080714072942): TIMESTAMP=`date +%Y%m%d%H%M%S` LOG=/log/log_${TIMESTAMP}.log I'm looking for a shell script which deletes all files which is older than 3 months from today. Regards, Bhagat (3 Replies)
Discussion started by: bhagat.singh-j
3 Replies

9. UNIX for Dummies Questions & Answers

Move A File With Same Date,don't Change The Desitination Dir Date

Assume, I created one file three years back and I like to move the file to some other directory with the old date (Creation date)? Is it possible? Explain? (1 Reply)
Discussion started by: jee.ku2
1 Replies

10. Shell Programming and Scripting

how to check whether the given file is 5 weeks older than current date

HI, I need to check whether the given file is 5 weeks older than current date ?? Can anyone give me the script for this ?? (1 Reply)
Discussion started by: risshanth
1 Replies
Login or Register to Ask a Question