Rename files based on Age ?
Posted: 22 Jan 2014 17:47
Can you rename files specific criteria, based on the files age ?
Forum for XYplorer Users and Developers
https://www.xyplorer.com/xyfc/
Search for the files you want to give one name and then rename those files.CookieMonster wrote:I have a huge list of files, some of those files were created, nine months ago, others the past 30 days. I want to batch rename all the files, but give the older files a different file name, then the newer files.
This could be done by a script.CookieMonster wrote:Can you rename files specific criteria, based on the files age ?
Or at least someone to help translate the requests into something that can be easily understood here -and- to avoid the apparent lack of doing reading, research and training based on other posts made here..TheQwerty wrote:Maybe you should hire a programmer to help with all your odd "time-saving" requests?
I think it's better to write how the script should work in plain English rather then in code speakStefan wrote:This could be done by a script.CookieMonster wrote:Can you rename files specific criteria, based on the files age ?
If you can't write a script, at least write the wanted logic in English words, like:
for each file in [select folder]
var = get modifcation date
if (today minus var == more than 90 days) then do this:
if (today minus var == less than 90 days) then do this:
next file
Perhaps somebody get an idea and the time to aid you....
Not necessary. Depends on what you want to do.CookieMonster wrote:Do you have to set the "select folder" as a variable ?
Code: Select all
// loop through the whole current list
// go to top to first item:
//sel 1;
//loop till end of list:
while ( "<curitem>" != "" )
{
//do something:
msg "<curitem>",1;
//select next item in list to work on:
sel "+1";
}
Code: Select all
// loop through the whole list
//sel 1; // go to top first, if you want.
while ( "<curitem>" != "" )
{
/*
See Help > Variables
<date> current date
<datem> modified date of the current list item
<datec> created date of the current list item
<datea> accessed date of the current list item
*/
//do an diff on current item against current date:
//datediff(date1, [date2=now], [interval=d])
$DateDiff = datediff("<datem>");
//check if DateDiff is greater than 90 (days here):
if($DateDiff > 90){
//if yes, do this:
msg "OLD ONE FOUND<crlf 2><curitem> - <datem> - $DateDiff days old.",1;
}else{
//if not, do this here:
msg "This is too young: <curitem> - <datem> - $DateDiff days old.",1;
}
sel "+1";
}
And it's my guess that until you begin to show some serious efforts on your own to learn scripting, you will soon find yourself not getting any assistance here because it appears you've constantly giving new specs and asking for changes to what has been provided...not trying to be harsh but just warning you that you're beginning to irritate some of those who've really spent a lot of time trying to help you already, ok?CookieMonster wrote:Stefan, I can read the script, but like some people when it comes to speaking a language, I have problems putting the language together![]()
![]()
Reading the scripts does help to make sense.
See..here's yet another case of a revison to what you want to do...My goal was the script would rename the older files a set name that I would be prompt with, then the younger files a set name, once again I would be prompt with, and finally the newest files, once again I would be prompt with. Regardless if there are (50) old files, those old file could be renamed as such; the first file would be <acme2>, each sequential file would be <acme3,4,5,6,7.....> if there is a letter in place such as; <acmeA7> then it would be <acmeB8,C9,D9 etc....> if it were to reach the end of the alphabet then a letter would be replaced with a number starting at 0.
Not everybody have to become a coder, OK?j_c_hallgren wrote:And it's my guess that until you begin to show some serious efforts on your own to learn scripting,CookieMonster wrote:
HuhMy goal was the script would rename the older files a set name that I would be prompt with, then the younger files a set name, once again I would be prompt with, and finally the newest files, once again I would be prompt with. Regardless if there are (50) old files, those old file could be renamed as such;
OK, sometimes it would nevertheless be better to learn scriptingthe first file would be <acme2>, each sequential file would be <acme3,4,5,6,7.....>
if there is a letter in place such as; <acmeA7> then it would be <acmeB8,C9,D9 etc....>
if it were to reach the end of the alphabet then a letter would be replaced with a number starting at 0.
Well anyhow, considering I don't have a solid grasp of the XY syntax. One could assume that a condition could check for an age criteria for a group of files, then the next group of younger files, then finally the youngest files which is what I've been leaning towards this whole time.Huh
But it would be from much help if youanybody could better format there postings.
Just use a few more line breaks and break your prose into shorter steb-by-step explanations.
I am not in the mood to even read such a mess of a word stream