Page 1 of 2

Renaming file(s) to modification date

Posted: 14 Oct 2008 22:28
by kartal
Hi

I want to rename files via shortcut so I need the script line for renaming with date and modification time.

Here is what I need(after renamed)

Original File(s) Name_ModifDate_ModifTime.ext

Re: Renaming file(s) to modification date

Posted: 14 Oct 2008 22:44
by admin
Create a new UDC Rename:
Caption: Append item's modified date and time
Pattern: *_<datem yyyymmdd>_<datem hhnnss>
Type: It's a Batch Rename pattern.

Assign a KS and you're done. :)

Re: Renaming file(s) to modification date

Posted: 14 Oct 2008 22:46
by ivan
admin wrote:Create a new UDC Rename:
Caption: Append item's modified date and time
Pattern: *_<datem yyyymmdd>_<datem hhnnss>
Type: It's a Batch Rename pattern.

Assign a KS and you're done. :)
Once again proves how wildcards are useful for renaming :P Now if only each renaming function had them... :wink:

Re: Renaming file(s) to modification date

Posted: 14 Oct 2008 23:57
by kartal
Twisted!!!!

thanks admin, you saved the day.

Re: Renaming file(s) to modification date

Posted: 15 Oct 2008 01:50
by serendipity
Thinking loud. In the right-click context menu of rename special, "date special" could be a good addition.

Re: Renaming file(s) to modification date

Posted: 16 Oct 2008 22:06
by kartal
COme to think of it, how about renaming with current date and time as well?

Re: Renaming file(s) to modification date

Posted: 16 Oct 2008 22:28
by ivan
kartal wrote:COme to think of it, how about renaming with current date and time as well?
Create a new UDC Rename:
Caption: Append current date and time
Pattern: *_<date yyyymmddhhnnss>
Type: It's a Batch Rename pattern.

Re: Renaming file(s) to modification date

Posted: 16 Oct 2008 22:29
by admin
serendipity wrote:Thinking loud. In the right-click context menu of rename special, "date special" could be a good addition.
For me, yes! (Although I have my scripts, UDCs, and POM all set up.) But not sure how many users love to attach modified-dates as much as I do. And in what style...

Re: Renaming file(s) to modification date

Posted: 16 Oct 2008 22:48
by serendipity
admin wrote:For me, yes! (Although I have my scripts, UDCs, and POM all set up.) But not sure how many users love to attach modified-dates as much as I do. And in what style...
Same here, I use POM too. And liek you said not sure how many really need it. I think unless there is more demand this can rest. And Style? I was dead sure you would ask this. I would simply leave it to user, since there are tweaks for [ListDateFormats] and [ListTimeFormats], one can reference those to rename special.
But again, all this user friendliness is for non-script users (which is good). I have my POMs in place.

Re: Renaming file(s) to modification date

Posted: 23 Oct 2008 13:15
by Steadyhands
How would I append the date to the end of the file like this:-

file.txt
file.txt.081023

I've played a bit with this but I must be missing the obvious solution as my first effort

Code: Select all

rename e, "<date yymmdd>"
removed the extension

Re: Renaming file(s) to modification date

Posted: 23 Oct 2008 13:37
by Muroph
use this:

Code: Select all

rename r, "(.+) > $1.<date yymmdd>";

Re: Renaming file(s) to modification date

Posted: 23 Oct 2008 13:49
by Steadyhands
Thanks heaps. :lol: :lol: :D

Re: Renaming file(s) to modification date

Posted: 23 Oct 2008 13:53
by admin
Steadyhands wrote:How would I append the date to the end of the file like this:-

file.txt
file.txt.081023

I've played a bit with this but I must be missing the obvious solution as my first effort

Code: Select all

rename e, "<date yymmdd>"
removed the extension
I expected this one to work:

Code: Select all

rename , "*.<date yymmdd> /e";
but it just replaces the extension. I'd say this is a bug. If the /e switch is present, then * should refer to the whole name (base+extension), right?

Re: Renaming file(s) to modification date

Posted: 23 Oct 2008 14:18
by TheQwerty
admin wrote:I expected this one to work:

Code: Select all

rename , "*.<date yymmdd> /e";
but it just replaces the extension. I'd say this is a bug. If the /e switch is present, then * should refer to the whole name (base+extension), right?
I'd agree with that.


Also, that regex pattern can be simplified further:

Code: Select all

Rename "r", "$ > .<date yymmdd>";

Re: Renaming file(s) to modification date

Posted: 23 Oct 2008 15:18
by admin
TheQwerty wrote:
admin wrote:I expected this one to work:

Code: Select all

rename , "*.<date yymmdd> /e";
but it just replaces the extension. I'd say this is a bug. If the /e switch is present, then * should refer to the whole name (base+extension), right?
I'd agree with that.
I'm not that sure anymore. It's a bit confusing:

Code: Select all

        Old     Pattern         New 
This is how it works now:
        a.jpg   *-<#3>          a-3.jpg
        a.jpg   *-<#3>.png      a-3.png.jpg
        a.jpg   *-<#3> /e       a-3
        a.jpg   *-<#3>.png /e   a-3.png

With the new way, the latter two would change as follows:
        a.jpg   *-<#3> /e       a.jpg-3
        a.jpg   *-<#3>.png /e   a.jpg-3.png
Now what's better?