I ran into a small issue. I would like to copy some files in the precise order they were created.
So the oldest files should be copied first and the newest ones last.
I tried
but the files are still not sorted properly. I was thinking, that maybe the system cannot tell them apart properly as the copy process is so fast, that they basically copy simulatiously. Sounds stupid, but for some reason when I use this command, they are not created at the destination in the order they are stored in the source folder.
I was thinking that maybe a sleep or something is needed in between each copy process. So copy the oldest file, sleep one second, copy the next one....
But I am not sure how to get this done properly.
It would be ideal if this could be solved without a script as I want to run this in an Android terminal.
Were the original files created substantially at the same time?
The output of 'ls -lt' is not a simple file list, I would have thought that it should be 'ls -t'.
There are some files that were created within seconds of each other. But most were created hours, days or months apart.
However, this does not seem to matter during the copying process because if I repeat the same command twice, the time of creation of the new files will differ.
So the same command gives different destination file order despite the same original files.
First run:
1
2
5
3
4
6
Second run:
2
3
1
5
6
4
But unlike the cp command, the ls always gives the same result for the original files.
That's why I was thinking of adding some kind of sleep command after each copied file because I'm guessing the problem is not the original sorting, but the speed of file creation. I just don't know how to do it.
Hello, how in bash i can get directory loop and order by creation date?
THX! :)
#!/bin/bash
for folder in /home/test/*
do
if ; then
echo $folder;
fi (12 Replies)
Can someone draw up a script that for every file, folder and subfolder and files that will copy the creation date over top of the modified date??
I know how to touch every file recursively, but no idea how to read a files creation date then use that to touch the modification date of that file,... (3 Replies)
Dear friends..
I have the below listing of files under a directory in unix
-rw-r--r-- 1 abc abc 263349631 Jun 1 11:18 CDLD_20110603032055.xml
-rw-r--r-- 1 abc abc 267918241 Jun 1 11:21 CDLD_20110603032104.xml
-rw-r--r-- 1 abc abc 257672513 Jun 3 10:41... (5 Replies)
I'm looking for a simple solution to rename a batch of files. All of the files in this directory start with a date in the format mm.dd.yy followed by a space and then additional descriptive text.
Example:
01.21.10 742 P.xlsx
02.24.09 730 Smith.xlsx
The information following the date can... (3 Replies)
I need to build a k shell script that will sort files in a directory where files appear like this "XXXX_2008021213.DAT. I need to sort by date in the filename and then move files by individual date to a working folder. concatenate the files in the working folder then start a process once... (2 Replies)
hi
Is there a way to sort files in the order they were created ,and move them to another directory one by one ,oldest being the first to be moved.
Thanks
Arif (4 Replies)
Im on HP/UX and am trying to find the command like an ll but that will sort showing the most currently modified programs first.
Can anyone help me with that? :cool: (2 Replies)
Howdy,
I'm trying to figure out how to move multiple files based on their creation date. If anyone can enlighten me it would be most appreciated!!
Thanks!
:D (1 Reply)