Hi everybody!
I need to perform a task with a script but I have no idea how to do it, I hope someone could help me:
- on my linux pc I have many folders with movies, tv shows, toons, ecc.
They are shared by a dlna server to my panasonic tv where I can browse and see them.
The problem is that they are sorted with date/time only and there's no way on the TV or on the dlna server to change the sort method to alphabetical.
What I need is a script that changes date/time (no matter to when, but every file should be 1 min or 1 hour or one day more than the previous) according to the alphabetical order, within each subdirectory of a master path.
Can you please help me?
ShriniShoo and protocol,
The last two digits in the timestamps you're incrementing in your scripts represent minutes. There are 60 minutes per hour; not 100. Most implementations of the touch utility will happily accept a timestamp with a minute specified as 60 through 99 as minute 0 throughout 39 of the next hour. Others may report an error and refuse to use that malformed timestamp.
On systems that do accept 60 through 99, your loops will use the same timestamp for several pairs of files set using the timestamps (201201010560 and 201201010600, 201201010561 and 201201010601, ... through 20120101599 and 2012010639) as synonyms, so if more than 60 files are processed using protocomm's code (30 with ShriniShoo's code), the resulting list will not be sorted alphabetically as requested.
This slightly more complex script should do what was requested as long as the filesystem containing the files being processed supports at least 1 second timestamp resolution, and none of the pathnames being processed contain any <newline> characters:
I used the Korn shell for testing, but this will work with any shell that supports POSIX standard shell arithmetic expansions (such as bash and ksh).
Change the /master/path in the script to the root directory containing the files you want to process. Once you have verified that the commands it prints would do what you want, remove the echo to have it actually run the touch commands.
Note that the NextSecond function only uses 28 days in a month to avoid the complexity of varying numbers of days in a month and leap year calculations. It starts using January 2, 1970 (instead of January 1st) to avoid using negative timestamps when running in timezones east of Greenwich. (Some systems allow negative timestamps for times before the Epoch; some systems use unsigned timestamps to allow a 32-bit time_t to get past the upcoming year 2037 problem.) Assuming you have enough space to sort a long list of pathnames, this script should easily handle more than a billion files without reusing any timestamps.
This User Gave Thanks to Don Cragun For This Post:
Hi,
If I change date and time in global zone, then it will affect in non global zones.
During this process what files will get affect in non global zones and which mechanism it's using to change.
gloabl zone:Solaris 11.3 X86
TIA (1 Reply)
I have a file hello.txt which was created today (today's date timestamp)
I wish to change its date timestamp (access, modified, created) to 1 week old i.e one week from now.
uname -a
SunOS mymac 5.11 11.2 sun4v sparc sun4v
Can you please suggest a easy way to do that ? (12 Replies)
Hello Experts,
There is a log file which has date stamp, I just wanted to change the date automatically on daily basis when it runs.
Tried the below, but no luck.
grep -i error /var/bv1to1_var/logs/bv03.bectondickinson.com/bvlog.out.`date +\%Y\%m\%d` | tee error_bv03.doc
I would highly... (10 Replies)
Hi, I am extracting a date string from the source file like this :
06/05/2014 16:04:00
I want to change it to 05-JUN-14 04.05.00.000000000 PM
I basically store the date in a variable. I got solutions to change date in dd-mmm-yyyy format using tr but I guess it works only with the "date"... (8 Replies)
I have a file that contains todays date(for ex- test_08/30/2013)
Now I want a script which will run and change the name of the file and put yesterday's date
(for ex- test_08/29/2013)
Please help.
---------- Post updated at 04:40 AM ---------- Previous update was at 04:31 AM ----------
I... (2 Replies)
Hi
Summary:
- Script will take 2 arguments
- Argument 1: Date/Time value in a particular format
- Argument 2: TimeZone value
Examples:
Argument 1:
a. "May 11, 2012 08:00:00 AM"
b. "Dec 21, 2012 12:21:12 PM"
c. "Oct 2, 2012 05:00:00 PM"
Argument 2:
a. MT or MST or MDT
b. ET
c.... (4 Replies)
Can someone please tell me how to change the time and date format in the menu bar. I get to System Preferences -- Language and Text, format, customize, but I can't figure out what to do next. I want to change, say from Tue May 4 to 5 4 2010. How the heck do I do this? (5 Replies)
HI ,
I have a list1 which consists of data that i have to search and a list2 which has the files that need to be searched .So basically i am using list1 on list2 to see if list1 data is present if found replace it .I have written the code using foreach loop for each list .This is taking the... (1 Reply)
Hi,
Could you please let me know the command to change my date /time beyond few days back. Currently when i am trying the below commands able to go beyond one day at max.
-->date
-->Mon Sep 29 19:31:58 EST 2008
-->export TZ=TMP40:00:00 (Changing the date beyond 40 hours)
-->Sun Sep 28... (4 Replies)
Hi -
I'd like to know if it's possible to change the time on a Unix box temporarily, do some stuff, and then set it back to the correct time.
I'm testing some code that reads a time (in hours) from a config file, and does something at that time. I want to be able to run regression test... (5 Replies)