Copy to same folder and add today's Date as a suffix.

Discuss and share scripts and script files...
Post Reply
Steadyhands
Posts: 24
Joined: 13 Sep 2006 11:47
Location: Brisbane, Australia
Contact:

Copy to same folder and add today's Date as a suffix.

Post by Steadyhands »

I was wondering if this is the best way to do this? Could be a problem if you use Copy Here with Suffix Number on other files in the folder.

Code: Select all

// Copy to same folder and add today's Date as a suffix.
Focus("List");#164;
 selfilter "-01";
 rename "b", "*.?.<date yymmdd> /e";
 rename s, "-01/";

Edited to include Focus Command.
Last edited by Steadyhands on 24 Mar 2009 01:42, edited 1 time in total.

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

Re: Copy to same folder and add today's Date as a suffix.

Post by serendipity »

Steadyhands wrote:I was wondering if this is the best way to do this? Could be a problem if you use Copy Here with Suffix Number on other files in the folder.

Code: Select all

// Copy to same folder and add today's Date as a suffix.
#164;
 selfilter "-01";
 rename "b", "*.?.<date yymmdd> /e";
 rename s, "-01/";
But #165 (Copy here with suffix date now) does the same.

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

Re: Copy to same folder and add today's Date as a suffix.

Post by Steadyhands »

No, #165 adds the date before the file extension. I like to add the date after the file extension so the original programs do not recognise the file as being associated.

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

Re: Copy to same folder and add today's Date as a suffix.

Post by serendipity »

Steadyhands wrote:No, #165 adds the date before the file extension. I like to add the date after the file extension so the original programs do not recognise the file as being associated.
Oh sorry, then you are right. But like you said you might have problems with selfilter "-01", I modified your code to this:

Code: Select all

  // Copy to same folder and add today's Date as a suffix.
    #164;
    setting HideFoldersInList;
    sortby c, d;
    sel 1;
    rename "b", "*.?.<date yymmdd> /e";
    rename s, "-01/";
    

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

Re: Copy to same folder and add today's Date as a suffix.

Post by Steadyhands »

Time to dig up an old post of mine.

My original version is playing up for some reason. If I run it on a file for the first time. I get the error message
Nothing selected in the file list

If I cancel the error message and run it again it works.

It's like there now needs to be a pause before the selfiter command.

If I run the whole thing in step mode it works first time.


This is what I've been using

Code: Select all

// Copy to same folder and add todays Date as a suffix.
Focus("List");#164;
 selfilter "-01";
 rename "b", "*.?.<date yymmdd> /e";
 rename s, "-01/";

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

Re: Copy to same folder and add today's Date as a suffix.

Post by admin »

Which version are you using?

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

Re: Copy to same folder and add today's Date as a suffix.

Post by Steadyhands »

oops forgot that bit.

9.90.0704

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Copy to same folder and add today's Date as a suffix.

Post by Stefan »

Steadyhands wrote:
I like to add the date after the file extension
so the original programs do not recognise the file as being associated.

This is what I've been using

Code: Select all

// Copy to same folder and add todays Date as a suffix.
Focus("List");
  #164; //copy here with increment
  selfilter "-01";
  rename "b", "*.?.<date yymmdd> /e";
  rename s, "-01/";
BTW, I don't know about 2008 but today one can use copyas:
copyas
Creates copies named [original name]_backup_20100117.[original extension] if today is 17-Jan-2010:

copyas "*_backup_<date yyyymmdd>.?";
For example for "Steadyhands":

Code: Select all

// Copy to same folder and add todays Date as a suffix.
// *             = basename
// .             = dot
// ?             = extension
// .             = dot
// <date yymmdd> = 110429

  copyas "*.?.<date yymmdd>";


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

Re: Copy to same folder and add today's Date as a suffix.

Post by Steadyhands »

Thanks Stefan, that is a much better solution.

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

Re: Copy to same folder and add today's Date as a suffix.

Post by admin »

Just FYI, your script probably failed because a backgrounded file operation was not finished yet. To make it work you to turn off backgrounding temporarily like this:

Code: Select all

Focus("List");
  Setting "BackgroundFileOps", 0;
  #164; //copy here with increment
  selfilter "-01";
  rename "b", "*.?.<date yymmdd> /e";
  rename s, "-01/";

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

Re: Copy to same folder and add today's Date as a suffix.

Post by Steadyhands »

Thanks

Post Reply