LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-28-2014, 08:10 AM   #1
Xanthari
LQ Newbie
 
Registered: Jan 2014
Posts: 2

Rep: Reputation: Disabled
Create Directory based on file creation date and move files


I need to move files from one directory into an sub-directory named based on the file creation date of the files being moved.

for example: I process a batch of files daily then copy the 'done' files down to a sub-direcotry for archive purposes before 'loading up' the new batch.

thanks in advance for any help.

-X
 
Old 01-28-2014, 11:30 AM   #2
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
Here's the first result that came up googling for 'check file creation date'
http://stackoverflow.com/questions/1...in-bash-debian

So actually you can't, but noatime might be a work-around.
All you need do then is get the date - probably the "Change" date, you'll have to check o that.
And create a nice script to 1) create a directory and 2) move all files there.
 
Old 01-28-2014, 11:32 AM   #3
buttugly
Member
 
Registered: Feb 2006
Distribution: distrohopper
Posts: 58

Rep: Reputation: 16
http://ubuntuforums.org/showthread.php?t=2132340
 
Old 01-28-2014, 11:44 AM   #4
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
One way to catch the actual creation date is to use inotifywait.
You could then script it so that inotify catches the date, creates a directory and, if you want, create a list of files together with creationdate. Then you can use that to move files to proper subdir.
A bit more complex, but not too complicated.
 
Old 01-28-2014, 01:37 PM   #5
Xanthari
LQ Newbie
 
Registered: Jan 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks guys, i appreciate the input!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a files creation date to it's file name? msmith88 Linux - Newbie 11 09-28-2018 03:48 PM
move files based on date graphicsmanx1 Programming 7 12-18-2012 01:49 AM
[SOLVED] Use date with touch to create new file with date based name craigjl Linux - Newbie 5 03-12-2010 09:46 AM
[SOLVED] how to rename a file based on it creation date limdel Linux - Newbie 11 09-23-2009 06:41 AM
Trying to move files beyond cutoff date in subfolders and retain directory structure Erik Mesoy Linux - Newbie 2 03-16-2008 08:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration