need script to copy image files to folders date wise

Discuss and share scripts and script files...
Post Reply
kotlmg
Posts: 298
Joined: 30 Jun 2010 17:14

need script to copy image files to folders date wise

Post by kotlmg »

hello sir,
i have a lot of image files like .jpg,.jpeg and .png in one folder. now i want to move all those image files to date wise folders .
images are available in D:\AVI\images\

captured images are
D:\AVI\images\2020-04-21_204539.png
D:\AVI\images\2020-04-21_204511.png

with regards,

highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Re: need script to copy image files to folders date wise

Post by highend »

And?

Code: Select all

listfolder() / quicksearch() / whatever()
A loop
gpc()
substr() / regexmatch()
moveto ...
99% the same procedure as in all other scripts you've requested...
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

eil
Posts: 1609
Joined: 13 Jan 2011 19:44

Re: need script to copy image files to folders date wise

Post by eil »

need same script, tried to do one, but spent few hours and can't understand how to get creation/modified date of item from variable in particular format?
it's wrong, but just to understand what i'm trying to do..

Code: Select all

      foreach($item, listfolder(), '|') {
		moveto <datem dd.mm.yy>, $item, , 2, , , 1;
      }
Win 7 SP1 x64 100% 1366x768

highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Re: need script to copy image files to folders date wise

Post by highend »

For this to work, "Configuration | General | Sort and Rename | Rename | [x] Allow move on rename"
must be ticked...

Code: Select all

rename "b", '<datem yyyy-mm-dd>\*', "p", listfolder(), 64;
?

Or whatever format you like regarding the modified date...

Do NOT replace the single quotes around the datem variable with double quotes!
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

eil
Posts: 1609
Joined: 13 Jan 2011 19:44

Re: need script to copy image files to folders date wise

Post by eil »

thank you for example, but feels kinda not what i want to do(plus dependant on that setting).

main problem is that i can't figure out(just as a knowledge for future scripts) - how to get date of item(not selected, but picked from variable) in particular format?
for example this gives me date, but i can't format it= property(#4, $item);
Win 7 SP1 x64 100% 1366x768

highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Re: need script to copy image files to folders date wise

Post by highend »

thank you for example, but feels kinda not what i want to do
That's the script you've posted as a one-liner (with a different date format) so what exactly is wrong with it?

XY has inbuilt properties, you can just use property("#date.m", $item)
and formatdate([date], [format], [shift_unit], [shift_num]) allows you to format that...
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

eil
Posts: 1609
Joined: 13 Jan 2011 19:44

Re: need script to copy image files to folders date wise

Post by eil »

highend wrote: 05 Jan 2021 11:34 so what exactly is wrong with it?
for example it gives no control over dates preservation.
highend wrote: 05 Jan 2021 11:34XY has inbuilt properties, you can just use property("#date.m", $item)
and formatdate([date], [format], [shift_unit], [shift_num]) allows you to format that...
property("#date.m", $item) gives me "name_of_week time_hh_nn_ss" and formatdate later says "i don't understand such date".
that's why i asked exactly how to get date in selected format from start. say for simply selected item <datem dd-mm-yy> works as desired, i need same for item from a variable.
Win 7 SP1 x64 100% 1366x768

highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Re: need script to copy image files to folders date wise

Post by highend »

Code: Select all

    foreach($item, listfolder()) {
        moveto formatdate(property("#3", $item), "dd.mm.yy"), $item, , 2, , , 1;
    }
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

eil
Posts: 1609
Joined: 13 Jan 2011 19:44

Re: need script to copy image files to folders date wise

Post by eil »

still says invalid date, may it happen you know what's wrong?(seems like not in script)
Win 7 SP1 x64 100% 1366x768

highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Re: need script to copy image files to folders date wise

Post by highend »

You could check your OS date format

Control panel - Clock and Region - Change date, time, or number formats
+ "Additional settings"

but I'm not aware of any format like that as a configurable setting "name_of_week time_hh_nn_ss"

What does text property("#3", <curitem>); exactly display for a selected item?
Does a fresh XY instance display the same?
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

eil
Posts: 1609
Joined: 13 Jan 2011 19:44

Re: need script to copy image files to folders date wise

Post by eil »

highend wrote: 05 Jan 2021 12:21What does text property("#3", <curitem>); exactly display for a selected item?
Does a fresh XY instance display the same?
it displays in format "Tuesday 12:54", "Monday 18:11", even in fresh.
so i see it's sometime about system date problem, will search for solution, thank you for all answers and script help.
;------------------
found it, "short date" was in strange format, though never touched it. still kinda strange, will add some safety in case local date settings on other OS maybe same "different".
Win 7 SP1 x64 100% 1366x768

eil
Posts: 1609
Joined: 13 Jan 2011 19:44

Re: need script to copy image files to folders date wise

Post by eil »

with the help of @highend in this topic, made a second version of script that operates not file-by-file, but first collects items with same date, to make less operations and everything overall faster.

Code: Select all

  $listOfItems = report("{Fullname}|{Modified dd-mm-yy}<crlf>");  						//get list of items in format: Fullpath|dd-mm-yy (modified date)
  msg "Date example:<crlf>".gettoken(gettoken($listOfItems, 1, "<crlf>"), 2, "|"), 32 + 1;  //chech date format
  while(true){
      if (!$listOfItems) { break; }													//break if list is empty
      $itemDate = gettoken(gettoken($listOfItems, 1, "<crlf>"), 2, "|");					//get date of first item(separate second part of report date entry)
      //echo $itemDate;
      $sameDate = formatlist($listOfItems, "f", "<crlf>","*$itemDate");					//get all items with same date
      $sameDate =replacelist($sameDate, "|$itemDate", , "<crlf>");						//clear report entried leaving only Fullpath
      //echo $sameDate;
      moveto $itemDate, $sameDate, , 2, , , 1; 										 //move items to folder named after "modified date"
      $listOfItems =  formatlist($listOfItems, "f", "<crlf>","!*$itemDate");					//exclude operated itemsfrom overal list
      //echo $listOfItems;
  }
Win 7 SP1 x64 100% 1366x768

sl23
Posts: 223
Joined: 03 Feb 2015 23:34

Re: need script to copy image files to folders date wise

Post by sl23 »

Very useful script, thank you highend and eil :tup:

Post Reply