Jump to content
Ketarin forum

Need help with changing date format![SOLVED]


Tomorrow
 Share

Recommended Posts

So basicly i have created a variable called:

{prettyversion}

...that extracts the latest version number from the applications website and set it to Custom Column 2.Custom Column is set to:

{version}

 

What i want to do is change the date format in version name of the downloaded file.For example currently it's:

 

SpyBot Search & Destroy Updates 2010-08-11.exe

 

But i want to change it into:

 

SpyBot Search & Destroy Updates 11/08/2010.exe

 

I really hate the yyyy-MM-dd format and prefer the dd/MM/yyyy format.

I know 0 about regex so if the solution involves this then please include few pointers to help me out.

Im not sure if this can be done with replace or multireplace.Ok the:

{prettyversion:replace:-:/}

...can but what about numbers and their order?

 

There are several other similar apps that use the same format and i'd like to change those too.

Edited by Tomorrow
Link to comment
Share on other sites

Maybe this topic holds the answer for me?: http://ketarin.canneverbe.com/forum/viewtopic.php?pid=3539#p3539

 

EDIT: Ah crap.I can't use "/" symbol in filename because then subfolders are created for each "/" symbol.

Ah well a dot is good too.

 

So that would be:

SpyBot Search & Destroy Updates 11.08.2010.exe

Edited by Tomorrow
Link to comment
Share on other sites

Ok i have managed to almost get what i want but i had to drop the version number and use use the modify dates of the files.This isn't completely reliable because sometimes the files have been updated but the website still shows the old date.

 

Either way this is what i used:

{appname} {f:dd}.{f:MM}.{f:yyyy}.{url:ext}

Link to comment
Share on other sites

I'd like to reiterate what hherrie said - with ISO 8601 format (yyyy-mm-dd) your operating system can very easily sort the files by date. No, it's not "cosmetically appealing" to many people due to their silly schooling - but if you think about it, having the values in order of descending significance (ie, like the metric system), it makes a hell of a lot more sense.

 

Using a dot also causes problems, especially under Windows, if you try to affect filenames using the "*" character. Your filenames will "change" everything prior to the FIRST dot, but everything after it will be preserved. It's very annoying...and I speak from recent experience ((completely unrelated to the topic at hand, but there's a setting option to change the default "dvd to mobile" output filenames in DVDFab to avoid the two dots in the resulting filenames - this makes batch renaming seasons of a TV show a LOT easier)).

 

My last rant on this will be your appname. You *really* should consider replacing the "&" in the filename with the word "and". This will avoid issues with execution of the file if the exe handler has been corrupted (quotes removed) or you fail to execute it with wrapping quotes. I know this doesn't sound like a big deal, but it's one of the ways malware extends the depth of infection under Windows, so ampersands in filenames should be avoided. To see just how dangerous it can be, imagine you have an application named "destroy" on your computer and within your path. If you type in the filename you created above into a command line, the "destroy" application would be executed. While this is a reasonably small likelihood of infection, why risk it? Don't use ampersands in file or folder names if it can be avoided.

 

 

If you're still interested in using a funky date format, though, you can re-sort the values using a variable like this (put this in the box for 'prettyversion'):

{version:split:-:1}-{version:split:-:2}-{version:split:-:0}

 

Then save the file as:

{appname} {prettyversion}.{url:ext}

Link to comment
Share on other sites

I don't know but my Windows 7 seems to sort files just fine despite this and atleast on the outside it uses the exact same form(dd.MM.yyyy):

 

sdmc.jpg

 

I've yet to have problem with filenames with a dot inside though.

I'm not to worried about malware(the ampersand issue).Haven't had an infection in years.

Link to comment
Share on other sites

The other thing is, if you have a dozen of these files in the same folder, copy them off to a USB stick, and then try sorting them by "date", you'll find that often the sort fails. Windows, DOS, BASH and other shells don't see the same dates the same way. The only reliable way is to use the filename, and the only way to sort "by name" and get the dates sorted correctly is to use ISO8601 format (year, month, day).

Link to comment
Share on other sites

  • 1 year later...
...with ISO 8601 format (yyyy-mm-dd) your operating system can very easily sort the files by date...

Using a dot also causes problems, especially under Windows, if you try to affect filenames using the "*" character. Your filenames will "change" everything prior to the FIRST dot, but everything after it will be preserved...

 

...You *really* should consider replacing the "&" in the filename with the word "and". This will avoid issues with execution of the file if the exe handler has been corrupted (quotes removed) or you fail to execute it with wrapping quotes. I know this doesn't sound like a big deal, but it's one of the ways malware extends the depth of infection under Windows, so ampersands in filenames should be avoided. To see just how dangerous it can be, imagine you have an application named "destroy" on your computer and within your path. If you type in the filename you created above into a command line, the "destroy" application would be executed. While this is a reasonably small likelihood of infection, why risk it? Don't use ampersands in file or folder names if it can be avoided.

Wow! That was really interesting...

 

I've been using the yyyy.MM.dd date format for years now, including in my custom "regional settings" for date in Windows XP. Now you've got me wondering if it's worth or not changing it all to yyyy-MM-dd... I've never encountered a problem with my format; sorting is fine, finding (with "Everything 1.2.1.451a") is fine, running is fine and renaming (with "ReNamer 5.60+ Beta 13") is fine; I really wonder if I should postpone this change until it's really necessary (which basically means when I first encounter a problem), since it will probably be a lot of work... (there are already many scripts, excel spredsheets, routines, etc that are configured to use the "dot-separator" format).

 

About the "&" character, I also have been using it... As a general rule, ever since the 8-char DOS names, I always avoided using most special characters in filenames, specially Portuguese accented characters like é, á, ç, ã, ô, etc; I even have a special "translit" alphabet in "ReNamer" to automatically Rename files that do have "forbidden" characters; but there came a point, after some years using WinXP, where I gave up and started allowing for "&" and "+" characters into the filenames. Never had any problems after that, but I guess in order to avoid future problems I could reconsider. I will have to analyze the implications of renaming all files that currently use those characters more carefully before committing to the change.

Link to comment
Share on other sites

The dash-vs-dot thing isn't as big of a deal as the ampersands, but on some operating systems or with some settings applied, it can be ugly. Here's an example that demonstrates several issues related to the dots.

 

The ampersand (&) issue is far more significant for what we do, though. Using an ampersand in a filename will result in attempts to execute it on some platforms failing completely, or causing problems. Here's an example. Open a command prompt and type this:

nothing&echo.txt

You should see something like:

'nothing' is not recognized as an internal or external command,
operable program or batch file.
txt

The first couple lines mean that "nothing" isn't a valid command, but the "txt" on the next line means that the "echo" command successfully ran. Imagine how ugly it can get when you use the wrong filenames? Command & Conquer : you just opened a shell! File & erase : you just deleted something. Some vendors use an ampersand in their name (O&O, for example), and many people (myself included) create single-character batch files and shortcuts to effect faster command controls. Spiffy stuff. And potentially dangerous when used together. Since it's impossible to know (unless you ONLY ever use these installers on your own computers) what the system configuration is going to be of the target machine, it's better to just play it safe and not use ampersands in file names.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.