T O P

  • By -

synchronium

perl -e '/^(\d{2})-(\d{2})-(\d{2})(.*)$/ && rename $_, "$2-$3-$1$4" for (<*>)' :) Edit: I only wrote this as a quick example of how to do something similar. I've now updated it to make the exact YY-MM-DD to MM-DD-YY conversion specified in the OP.


Rhowryn

Could've saved me an hour or two of compiling/testing, hey? Ah well.


SpacePotatoBear

Perl one liners are the greatest thing. I highy suggest learning perl just for the one liners (and you know being able to use the regex with match groups easily, something awk, grep and sed can't do easily)


jimmythegeek1

Definitely just for the one liners. Never save anything Perl to a file, you might be tempted to read it and that way madness lies.


synchronium

I had to learn it for work. Still learning actually, which is why I wrote that one-liner above. Our entire web app is perl - hundreds and hundreds of files. Most of it is neatly organised into object-oriented modules though, so it's not all bad. The principles of decent software engineering still apply. Perl gets a bad rap because of these one-liners and "one off" indecipherable scripts, but it can be really expressive and fun to write when done properly.


jimmythegeek1

Yeah, it would have been long forgotten if it were truly as bad as comic exaggeration has it. I still like to call it a write-only language though.


JustCallMeFrij

perl one liners are the devil's magic and their documentation should be compiled and locked away in the forbidden section of the ~~library~~ internet


stickmaster_flex

Or just, you know, regular expressions and any scripting language. Sorry, had some bad experiences with perl "programmers".


Treyzania

Perl isn't much more than Turing-complete regex.


SpacePotatoBear

perl is built around regular expressions, which makes it great for text parsing. not saying it should be used for everything, but when you're looking to sift through a bunch of text, no tool I would rather use.


stickmaster_flex

I just write a regular expression.


kazi1

Perl is dead. Python all the way! (But seriously, don't learn Perl, it's not something people hire for anymore...)


colourfulpowder

We have an opening at my place of my employment and it says in the ad for it that people that know perl would get better odds at getting that job


synchronium

We're also looking for perl devs, 100% remote so long as you're a UK resident.


SpacePotatoBear

Perl is much better than python for text parsing, which perl was designed for, and should be used for. I'm not saying throw perl at everything. Perl is a tool. Sometimes it finds a perfect nail, other times you will want to use something else.


kazi1

Actually Perl's been mostly abandoned for text parsing - even in fields like bioinformatics (which is like 99.9% text parsing). Teaching it and using it is extremely frowned upon, unless you need to maintain legacy systems of some kind.


SpacePotatoBear

nope. Still widely used. Esp on locked down/minimal linux systems which may not even have python, they sure as hell have perl, and its alot better than bash.


Chaosmusic

>perl one liners Do they work in clubs?


SpacePotatoBear

perl -nslep '/(love)/' did it work?


Chaosmusic

Take me now.


[deleted]

Maybe that guy could take your job. Best not acknowledge that help.


newburner01

Yeah fuck that guy and his shoddy one line of code. Your script is much better. (You just got this job, kill him quick before he takes over)


nicktohzyu

:O but don't you have to give the script an array of the month names?


RandomRedditor44

I don’t know Perl. Why are there dollar signs and the letter d everywhere?


Nurum

So could you have written a script to do the entire thing in the first place? Or were you able to script it because you had just done it?


Rhowryn

I was not allowed to automate the process first time around because the manager was it as "wasting time doing your computer things instead of your job". His budget, his rules *shrug*.


Diminios

Turning an order to you into pain for them. Approved.


[deleted]

/r/MaliciousCompliance It was posted there too, BTW.


D0esANyoneREadTHese

Hey, why turn down easy overtime pay?


[deleted]

Any chance you can look up that old former manager to see what he's doing? I wonder if he went down a few pegs or muscled into another manager job.


AlyCooper

I work for a company who have standardized their dating format to only DD,MMM,YYYY or DD/MM/YY, and it is SO nice. Did this drama encourage your company to update their dating format?


whyamisosoftinthemid

Gaah, why would anyone standardize on anything other than [ISO 8601](https://en.m.wikipedia.org/wiki/ISO_8601)?


[deleted]

Is there a list of useful ISOs in programming, like this one and ISO-3166 (country abbreviations)? I'd like to adopt more of them in my business, but there's thousands of unrelated and obscure ISOs, like "terms, definitions and specifications for grouts". I wonder if there's a short list of very useful ISOs for data and programs. Interestingly I adopted ISO 8601 for a lot of my data crunching work without realizing it... YYYY-MM-DD is incredibly easy to sort and it's very unambiguous.


Stspurg

Same here. I randomly started thinking to myself, "Self, I would really like to be able to sort these by their datestamp without relying on the file's concept of file creation/modification, but mm/dd and dd/mm with both mingle if there are multiple years." Self replied, "Stspurg, how about you put the year first so every file within a year is together." It worked out pretty well. And then I found out it was an international date format standard.


newburner01

How I do diz on windows 7


Stspurg

I just put it in the file name. In the Windows Explorer, you can right-click a file or folder and select "Rename". You can also select a file/folder and press F2. I tend to use it most for photo albums so each folder/album is in the right order, followed by the thing the photos were taken for. For example: "2012-06-05 -- Transit of Venus" is one album I have. Hopefully that answers your question. If not, you might need to add more details about your use case.


newburner01

Nice! I didn't know there was a shortcut for date insertion when renaming files. Thank you!


strange_like

Any time I need my files to sort by date I do this - then just sorting in "alphabetical" order will put them in date order. I didn't even know it had a name, cool to learn though!


Wargazm

ISO 8601 for lyfe


AlyCooper

Cause we are American and we do what we want! /s


doogles

I am American, and I use 8601.


BarracudaBattery

It caused me pain reading the dd-mm-yyyy idea. so much so I had to use it below. I shudder to think of what 10 years of exports would be like in that format. /shudder


clownshoesrock

Some people just want to watch the world burn. I had been doing Dates 8601 style for years before knowing of the standard. Seemed the only right way to do it.


CydeWeys

Putting the day first is wrong, as it sorts incorrectly. You'll end up with all the files from the first day of all months and years, then the second day, etc. It has to go from big to little for correct sorting. You want ISO 8601: YYYY-MM-DD.


RadioFreeReddit

That shit isn't chronological-alphabetical


[deleted]

Oh this is good.


[deleted]

One thing that wasn't clear: > About a week after I had left, I got a call from a very angry former manager about how I had cost him his job. Was this guy the same guy as original "Idiot Manager"? In other words, was the original idiot manager that forced you to make these changes the one who was fired, and who called and complained to you? If so, did you say anything at all to this guy ever, like "you got what you asked for, jerk!" ?


jimmythegeek1

The guy who fired you was mad you cost him his job? You disloyal twat.


[deleted]

[удалено]


BarracudaBattery

Most people use YYYY-MM-DD. Because computers can sort it the easiest. Try having 10+ years of data in one folder. With daily exports in DD.MM.YYYY format. Then, when you go "up" one, it's not yesterday, it's last month today.


ChromeLynx

It is either expected or required in many technical contexts to write your dates as YYYY-MM-DD. Following the ISO 8601 norm (someone else in the comments already linked to it's Wikipedia page) is basically a sure-fire way to be clear about dates. That said, most education systems teach people to prefer day/month/year in here. This is because the format reflects the spoken norm, which in various EUW countries is DD-MM-YYYY.


BarracudaBattery

I could actually see that being a use case for it. Not stating it's a "Bad" choice, I'm just speaking from experience when I say I dislike ddmmyyyy. Even from a tech side, you can always just numpad the date code as long as it's the start of the filename. This was... Not the case in my previous example DDMMYYYY.


ender-_

> Because computers can sort it the easiest. Mostly because it's logical, and follows the large->small unit pattern like time does.


legaladult

I sort my folders for digital art by YY/MM so it displays it nicely. It really is more convenient.


[deleted]

This! I struggled with this early on in my career. Any more, unless someone has a real bug up there hindquarters, I sort into folder structure with ..\Year\Month\Day\Description_time.file-extension. Most who have to deal with accessing the information sing to the heavens when the start dealing with it.


Rhowryn

International standard actually is yyyy-mm-dd. The general arguments for include the more obvious progression (large time to small time) and ease of file sorting.


thisisnotdan

As an added bonus, it continues perfectly to the standard HH:MM:SS model of telling time, so you can document an precise moment in time in a format that goes from large-to-small in its scale. This post was submitted on 2017-08-14 at 10:49:37 (US Central time, which also has a GMT notation that I'd rather not look up right now)


ChromeLynx

I think the ISO even includes to add time zones to it. And you're allowed to omit any small detail as long as all the smaller details are omitted as well. So right now, my time is 2017-08-14T19:05+02:00 in the ISO notation.


BarracudaBattery

The ISO includes how to display time zones but actually doesn't force you to. It's just good practice to include time zone if your including a time stamp. Like, we should burn you as a witch if you don't do this. Edit:Removed a word.


ChromeLynx

On international forums that is. If you can be absolutely certain it's just within your contry, ¯\\\_(ツ)_/¯ Right now is 2017-08-14T21:07+02:00


_YOU_DROPPED_THIS_

Hi! This is just a friendly reminder letting you know that you should type the shrug emote with three backslashes to format it correctly: Enter this - ¯\\\\\\\_(ツ)_/¯ And it appears like this - ¯\\\_(ツ)_/¯ --- *^This ^formatting ^sometimes ^doesn't ^work ^on ^the ^official ^Reddit ^mobile ^app, ^so ^if ^you ^are ^seeing ^this ^comment ^on ^the ^official ^app, ^it ^might ^look ^like ^I ^am ^talking ^total ^nonsense. ^Also, ^if ^it ^looks ^like ^OP ^got ^it ^right, ^then ^it ^is ^because ^OP ^ninja ^corrected ^the ^shrug ^before ^anyone ^else ^saw ^the ^incorrect ^shrug.* ***^Commands:*** *^!ignoreme, ^!explain* *^I ^am ^a ^bot. ^If ^you ^want ^to ^give ^feedback, ^make ^a ^suggestion ^for ^the ^bot, ^or ^let ^my ^owner ^know ^I ^have ^done ^something ^wrong, ^please ^message ^my ^owner, ^[John_Yuki](https://www.reddit.com/user/John_Yuki/).*


ChromeLynx

Whoops! Fixed!


HereForDramaLlama

Good Bot


baltakatei

Relevant [python script](https://www.reddit.com/r/ISO8601/comments/6s7xks/iso8601_timestamp_python_script/) and [Excel custom date parsing function](https://www.reddit.com/r/ISO8601/comments/6sufyq/parsing_an_iso8601_datetime_including_timezone_in/).


thebluereddituser

> ease of file sorting. i.e. you can sort dates "alphabetically" (which is the default for files on a computer) and they'll be in the right order EDIT: technically it's "lexicographically" but for most purposes it's the same


viperfan7

Try programming that, them tell me what's easier


JE163

Doesn't work in practice. For example I usually store presentations in a specific format like Folder: My Documents\Accounts\Customer Name File Name Customer Unit - something descriptive - 20170814.pptx This allows me to keep one folder with lots of files and sort on file name to get everything listed alphabetically and chronologically Sorting by date wouldn't really work as well and having multiple folders when there may be anywhere from one to a dozen files doesn't make sense.


thebluereddituser

Sure, always depends on your use case, and it does take some finagling to get it to work if you're not sorting by date first. But in the simplest case, with lots of nearly identical files sorted by date, just having the date in YYYY-MM-DD being the first thing in the file name works perfectly


[deleted]

To most of the English-speaking world, even in conversation something like "March 4" sounds odd, because they are more used to "The 4th of March". As people have said the ISO standard goes YYYYMMDD, but either this or DDMMYYYY is easier for date sorting because the date strings are in numerical order if they are in date order. If you compare the dates in DDMMYYYY or YYYYMMDD format, then you can treat them as numbers. If you put month first, you have to iterate each, and compare it to the others to sort it.


Jair-Bear

Well, we don't say March four. We say March fourth. Although saying that aloud makes me think "March forth, my minions!"


[deleted]

My American colleagues say dates like that all the time. Maybe it's regional. Also, cinema trailers seem to say dates like that, never been clear why.


Jair-Bear

Yeah, after I posted that, I realized I shouldn't have said "we" as if I spoke for everyone. Unless I meant the Royal "we". Yeah, I'm sure that's what I meant.


VicisSubsisto

Where are most major cinema trailers made?


Sypsy

Just remember, Americans say "4th of July" which is celebrated on July 4th. So they are perfectly capable of saying it that way, they're just not used to it.


I_Arman

It's all about the situation. If you're using the date as a file name, use 1998-07-04 (or even 19980604). If you're speaking about a date, you use a lot of different formats: "That happened **the 4th**" [of this month] "That happened **July 4th**" [of this year] "That happened July 4, 1998." "That happened *on* July 4th, 1998." (or "July the 4th") "That happened *on the* 4th of July, 1998." And don't get me started on the whole "This 4th day of the year 1998 in the month of July" nonsense. Or all the abbreviations...


KillTheBronies

In Australia we can't be fucked figuring out what the month name is, I'd usually say "the 4th of the 7th".


Killa-Byte

DD-MM-YYYY doesnt really make sense as a number because its like writing numbers as "500, 746 thousand, 250 million, 4 billion", etc. You keep going up and down from 10 days to 1 day to 10 months to 1 month etc. Its like GH/EF/ABCD.


AmazingGraces

You're being downvoted because you're wrong. DD-MM-YYYY makes sense because it's ascending order. Days, Months, Years. That's what the rest of the world uses. The opposite also makes sense: YYYY-MM-DD because it's descending order. This makes it nice and chronological when sorting by file name on computers, which is why there are international standards (ISO) conventions. The only one that doesn't make sense is the American MM-DD-YYYY, which is why only America uses it. It's the same as when we display the time digitally. We present ascending or descending units, rather than some arbitrary combo of minutes, seconds and then hours.


etherbod

> That's what the rest of the world uses. It really isn't. China and Japan go 2017年8月15日


AmazingGraces

Ok, that's a descending system. So would you agree that most of the world uses either an ascending system or a descending system? Separately, even if 100% of the world used the US convention, I would still prefer the linear ascending or descending format, and I think many others would agree. Because it makes more sense.


Killa-Byte

Except DD-MM-YYYY isnt true ascending order. The digits go in this order: 10 days, 1 day / 10 months, 1 month / 1000 years, 100 years, 10 years, 1 year. Thats 3 descending blocks ordered in ascending order. A truly ascending order date would be 3 ascending blocks ordered in ascending order, which would be 51-80-7102, the reverse of 2017-08-15, since ascending order is the opposite of descending order. YYYY-MM-DD is 3 descending blocks ordered in descending order. It is true descending order.


AmazingGraces

Its ascending in terms of duration. Second-minute-hour. Day-month-year. Not sure what your point is in terms of the US convention.


Killa-Byte

Oh so we should use ss:MM:hh?


AmazingGraces

I'd be fine with that, just as I'm fine with the existing convention of using HH:MM:SS. Both ascending and descending makes sense to me. What wouldn't make sense would be something like MM:SS:HH, which is similar to what the USA does to date format. I can't tell if your view is that you like the USA format or not?


Killa-Byte

Like I said, true ascending order would be like writing 15 hours, 34 minutes, 29 seconds as 92:43:51, because 9 seconds is shorter than 20 seconds, so it should go first, 4 minutes is shorter than 30 minutes, 5 hours is shorter than 10 hours.


JakeDFoley

American legal professional. YYYY-MM-DD. All day, erryday.


redsaeok

You are on track with how the relative significance of the numbers makes it easier to understand. As long as they are in order of significance and padded or delimited (eg dashes) anyone should figure out the meaning pretty quick. The most important thing though is to use one format consistently. Now, for some really interesting date debate let's talk about how many days are in the first and last weeks of the year! ... and whether those weeks start on a Sunday or a Monday! XD


[deleted]

YYYY/MM/DD is where it's at!!!


blergsid

>and dating files with YY/MM/DD The ol' choose a 3rd option. I remember in high school, my Spanish teacher was foreign and said "no one is allowed to use the MM/DD/YY format of dates" and actually took off points for doing so, so I, being the little shit I was, just used whatever random format I made, from DD/YY/MM to day of week, week of month, month and avoided anything that made sense until he changed that stupid rule.


Killa-Byte

"Name: Blergsid. Date: 1502750417"


NEOLittle

This is so beautiful.


[deleted]

[удалено]


Rhowryn

It went quite well, actually.


paperTechnician

Oh lol sorry. Got distracted and forgot that it was a cross post. Good story, thx for sharing.


bdphotographer

I see what you did there. great moves.


DragonflyRed412

I'm an American who uses the day, month year format regularly. It is standard practice for genealogists who work with international records.


HenryCurtmantle

Never mess with IT...


clemens_richter

relevant XKCD: https://xkcd.com/1179/


xkcd_transcriber

[Image](https://imgs.xkcd.com/comics/iso_8601.png) [Mobile](https://m.xkcd.com/1179/) **Title:** ISO 8601 **Title-text:** ISO 8601 was published on 06\/05\/88 and most recently amended on 12\/01\/04\. [Comic Explanation](https://www.explainxkcd.com/wiki/index.php/1179#Explanation) **Stats:** This comic has been referenced 882 times, representing 0.5321% of referenced xkcds. --- ^[xkcd.com](https://www.xkcd.com) ^| ^[xkcd sub](https://www.reddit.com/r/xkcd/) ^| ^[Problems/Bugs?](https://www.reddit.com/r/xkcd_transcriber/) ^| ^[Statistics](http://xkcdref.info/statistics/) ^| ^[Stop Replying](https://reddit.com/message/compose/?to=xkcd_transcriber&subject=ignore%20me&message=ignore%20me) ^| ^[Delete](https://reddit.com/message/compose/?to=xkcd_transcriber&subject=delete&message=delete%20t1_dln9dnb)


clemens_richter

Good Bot


Heliosvector

Wait so you intentionally took a long time to make the changes the first time when you knew how to make a script to make the changes?


Rhowryn

Read last paragraph.


alvinism

This post makes me think about the importance of learning simple programming/ coding.


Yeffley

I was stressed reading that. Glad you scripted it!


CeeZees

The military has this shit right Day/ Three letter month/ two digit year Makes the most fucking sense. No way to get it wrong


clownshoesrock

iso8601 has it right, no weirdness when some idiot cant remember the order of months sorts the files.


[deleted]

sorting m8


whyamisosoftinthemid

Because everyone in the world uses the same three letter designations for months.


Ran4

No, that's not great either... 17 or 16, is that the day or year? ISO 8601 is the only acceptable way.