Renaming file(s) to modification date

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
kartal
Posts: 208
Joined: 14 Aug 2008 18:06

Renaming file(s) to modification date

Post 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

admin
Site Admin
Posts: 66075
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Renaming file(s) to modification date

Post 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. :)

ivan
Posts: 577
Joined: 02 Apr 2008 12:52
Contact:

Re: Renaming file(s) to modification date

Post 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:
Windows Vista Business SP1 32-bit, Logitech MX400 mouse, SetPoint 4.60.122
Image

kartal
Posts: 208
Joined: 14 Aug 2008 18:06

Re: Renaming file(s) to modification date

Post by kartal »

Twisted!!!!

thanks admin, you saved the day.

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Renaming file(s) to modification date

Post by serendipity »

Thinking loud. In the right-click context menu of rename special, "date special" could be a good addition.

kartal
Posts: 208
Joined: 14 Aug 2008 18:06

Re: Renaming file(s) to modification date

Post by kartal »

COme to think of it, how about renaming with current date and time as well?

ivan
Posts: 577
Joined: 02 Apr 2008 12:52
Contact:

Re: Renaming file(s) to modification date

Post 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.
Windows Vista Business SP1 32-bit, Logitech MX400 mouse, SetPoint 4.60.122
Image

admin
Site Admin
Posts: 66075
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Renaming file(s) to modification date

Post 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...

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Renaming file(s) to modification date

Post 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.

Steadyhands
Posts: 24
Joined: 13 Sep 2006 11:47
Location: Brisbane, Australia
Contact:

Re: Renaming file(s) to modification date

Post 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

Muroph
Posts: 561
Joined: 21 Aug 2007 16:13

Re: Renaming file(s) to modification date

Post by Muroph »

use this:

Code: Select all

rename r, "(.+) > $1.<date yymmdd>";
My shared scripts:
TeraCopy Integration, Tag Manager, Comments Menu, Text Replacer, Image and Media Tools, Checksum Calculator, Video Calculator
only 5 URLs are allowed on the sig...

Steadyhands
Posts: 24
Joined: 13 Sep 2006 11:47
Location: Brisbane, Australia
Contact:

Re: Renaming file(s) to modification date

Post by Steadyhands »

Thanks heaps. :lol: :lol: :D

admin
Site Admin
Posts: 66075
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Renaming file(s) to modification date

Post 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?

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Renaming file(s) to modification date

Post 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>";

admin
Site Admin
Posts: 66075
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Renaming file(s) to modification date

Post 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?

Post Reply