Page 1 of 1

need script to copy image files to folders date wise

Posted: 21 Apr 2020 17:16
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,

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

Posted: 21 Apr 2020 17:51
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...

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

Posted: 05 Jan 2021 10:50
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;
      }

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

Posted: 05 Jan 2021 11:01
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!

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

Posted: 05 Jan 2021 11:27
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);

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

Posted: 05 Jan 2021 11:34
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...

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

Posted: 05 Jan 2021 11:51
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.

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

Posted: 05 Jan 2021 12:06
by highend

Code: Select all

    foreach($item, listfolder()) {
        moveto formatdate(property("#3", $item), "dd.mm.yy"), $item, , 2, , , 1;
    }

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

Posted: 05 Jan 2021 12:11
by eil
still says invalid date, may it happen you know what's wrong?(seems like not in script)

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

Posted: 05 Jan 2021 12:21
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?

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

Posted: 05 Jan 2021 12:39
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".

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

Posted: 04 Feb 2021 18:29
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;
  }

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

Posted: 25 May 2021 19:05
by sl23
Very useful script, thank you highend and eil :tup: