Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

Script that can scan all the folders and sub folders inside a folder and sort files according to the created dates.

Hi,

Script that can scan all the folders and sub folders inside a folder and sort files according to the created dates.
Foldername has to be in this format

DD-MM-YYY

Actually there are photo files Jpg in these folders and sub folders so need to create folders according to the date and put all the files inside the folder.
Ex:
I have folder structure like this
Folder1 > Folder1
                Folder2
                 Folder3> Folder1
So when its sorting folders have to be created within the folders should not get outside files into the folder.

Regards
Sharath
0
bsharath
Asked:
bsharath
  • 3
  • 2
1 Solution
 
ozoCommented:
I'm not quite sure what you mean
Do you want something like
find . -type d -exec ls -lt *.jpg \;
0
 
bsharathAuthor Commented:
I want a way to sort the jpg files according to the created date.But want then not to be moved out of the folders.
The script need to find them sort them by creating folders inside the folders.
0
 
ozoCommented:
so are you saying that when we find a file named
folder1/folder2/folder3/photo.jpg, which was created on 2007-October-13,
you want to rename it to
folder1/folder2/folder3/13-12-007/photo.jpg?
0
 
bsharathAuthor Commented:
13-12-07 has to be the foldername.You are right....
0
 
ozoCommented:
perl -MFile::Find -MPOSIX -e 'find(sub{return unless /\.jpg$/;$d=strftime"%d-%m-%y",localtime((stat)[9]);mkdir $d or warn "$d $!";rename $_,"$d/$_" or warn"$d/$_ $!"},".")'
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now