copy images from camera

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
shemesh
Posts: 23
Joined: 19 Mar 2019, 16:45

copy images from camera

24 Mar 2019, 14:54

hi,
before diving into a new project, i wonder if there is something (or similar) already existing for...
copy images from camera to computer

should do:
- select source folder.
- select target folder.
- go over all files in source folder & sub to read file name and creatrion time
- from image creation time make a folder name
- go to target folder and check if this folder (by date) name exist, if no than create it
- in this folder check if a file with same name & creation time exist...
- if no than copy the image.

is there such a thing?
or similar to be base for me?

TNX.
shemesh
Posts: 23
Joined: 19 Mar 2019, 16:45

Re: copy images from camera

25 Mar 2019, 13:45

someone? please?
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: copy images from camera

25 Mar 2019, 13:47

sounds good
make you own one
User avatar
Scr1pter
Posts: 1275
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: copy images from camera

25 Mar 2019, 14:27

For the folders I think you don't need to select anything.
You could specify the source and the target folders (or do they really change)?

Regarding the creation time you can work with FileGetTime
Save this value to a helper variable.
Loop, Files, targetFolder, D will list through the target folder.
You can compare every folder with the value of your helper variable (if-statement)
After that, if none was found, use FileCreateDir.
All those commands can be found in the Documentation:
https://www.autohotkey.com/docs/commands/FileGetTime.htm

But honestly, there's a lot of things to do.

I think this is too much for a beginner.
Try to create something easier...
Once you have some good experience and knowledge, you might create such a script without problems.

Or beg IMEime to code it for you :mrgreen:

Cheers!
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
shemesh
Posts: 23
Joined: 19 Mar 2019, 16:45

Re: copy images from camera

25 Mar 2019, 15:23

tnx...
me not realy a beginner i did already wrote some nifty ahk scripts (few years ago)
i loved it and know the power and ease of dev of it.
just thought there must be something similar, or some script to start with...
or...
IMEime - i beg you...
Kobaltauge
Posts: 264
Joined: 09 Mar 2019, 01:52
Location: Germany
Contact:

Re: copy images from camera

26 Mar 2019, 00:43

Go for it. Scr1pter gave you the solution in pseudocode. You only have to write it down.
Take your shot and if something doesn't work or your stuck you can ask the detail.
shemesh
Posts: 23
Joined: 19 Mar 2019, 16:45

Re: copy images from camera

26 Mar 2019, 14:29

ok...
first problem...
in source folder i have hundreds of files, in target folder i have thousands of files
what would be the best and fast way to check if a file in source exist or not in target?? (unique by file name & creation time)
a loop within a loop?? that would be very not effecient
got some other idea?
User avatar
Scr1pter
Posts: 1275
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: copy images from camera

26 Mar 2019, 14:39

How can the target folder contain thousands of files, if the folder names are the creation time?
I highly doubt you shoot 1000+ photos a day.

Perhaps it makes more sense to extract the date of the files.
It means your target folder will have folders of each day you shot pictures.
E.g.:
Folder 1: 2019-01-25
Folder 2: 2019-01-31

I don't think you can say that A loop within a loop is not efficient.
Depends on the case.
To check if a file exists, there is a function named, well, FileExist() :)
https://www.autohotkey.com/docs/commands/FileExist.htm

P.S.
Instead of coding, try to create some flow diagram (Word, Paint or wherever) and post it.
Then both you and we will exactly know how the workflow should be like.

Cheers!
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
shemesh
Posts: 23
Joined: 19 Mar 2019, 16:45

Re: copy images from camera

26 Mar 2019, 15:35

i tought it might be more effecient to:
1) check if file from source (& subs) not exist in target (& subs)
2) show a list of "not existing"
3) act on that list only... make folder, etc

question arise:
a) can FileExist() search also in sub folders? how?
b) what does FileExist() check for? only same file name? name&size? or... ?
Kobaltauge
Posts: 264
Joined: 09 Mar 2019, 01:52
Location: Germany
Contact:

Re: copy images from camera

27 Mar 2019, 01:38

Start with this
In the source the file are named:

2019-03-26-001.jpg
2019-03-27-001.jpg
2019-03-27-002.jpg
2019-03-27-003.jpg

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

source := "D:\tmp\source\"
target := "D:\tmp\target\"

Loop Files, %source%\*.jpg, R  ; Recurse into subfolders
{
	sdate := StrSplit(A_LoopFileName, "-")
	syr := sdate[1]
	ymt := sdate[2]
	sdy := sdate[3]
	scn := sdate[4]
	;MsgBox, %syr% %ymt% %sdy% %scn%
	tfolder := target . syr . "-" . ymt . "-" . sdy
	if FileExist(tfolder)
	{
		FileMove, %source%\%A_LoopFileName%, %tfolder%
	}
	else
	{
		FileCreateDir, %tfolder%
		FileMove, %source%\%A_LoopFileName%, %tfolder%
	}
}
MsgBox, Done
User avatar
jmeneses
Posts: 524
Joined: 28 Oct 2014, 11:09
Location: Catalan Republic

Re: copy images from camera

27 Mar 2019, 01:58

Donec Perficiam
shemesh
Posts: 23
Joined: 19 Mar 2019, 16:45

Re: copy images from camera

27 Mar 2019, 08:30

here is what i got for a start
what you think?

Code: Select all

#SingleInstance force
#NoEnv
#Warn
SendMode Input 
SetWorkingDir %A_ScriptDir%

sourceFolder := % A_Desktop "\XXX"
destinationFolder := % A_Desktop "\AAA"

result := CopyFiles(sourceFolder, destinationFolder)
MsgBox % result.successCount " files copied`n" result.errorCount " files not copied"

CopyFiles(srcF, dstF)
{
    errorCount = 0
    successCount = 0
    Gui, Add, ListView, r20 w700, Name|Size|formatedTime|msg
    Loop, Files, %srcF%\*.*, R
    {
        msg =
        FormatTime, formatedTime, %A_LoopFileTimeCreated%, yyyy-MM-dd
        tfolder := dstF . "\" . formatedTime
        FileCreateDir, %tfolder%
        FileCopy, %A_LoopFileLongPath%, %tfolder%, 0
        if ErrorLevel
        {
            msg = could NOT copy %A_LoopFileFullPath% into %dstF%.
            errorCount ++
        }
        else
        {
            successCount ++
            msg = Success
        }
        LV_Add("", A_LoopFileName, A_LoopFileSizeKB, formatedTime, msg)
    }
    LV_ModifyCol()
    Gui, Show
    return {errorCount: errorCount, successCount: successCount}
}
shemesh
Posts: 23
Joined: 19 Mar 2019, 16:45

Re: copy images from camera

29 Mar 2019, 06:26

i have uploaded my code to github
feel free to improve on it, add stuff, etc.
https://github.com/Shemesh/CopyFilesByDate

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: scriptor2016 and 143 guests