Page 1 of 1

Copy Files on every USB-Drive

Posted: 19 Sep 2020, 08:36
by Marius-Scripter
I want to copy Images on every USB-Drive
Like so:

Code: Select all

GetDrive, DriveList, List, REMOVABLE
For Drive in Drivelist { ;Not real code
    FileCopy, *.png, %Drive%
    FileCopy, *.jpg, %Drive%
}
MsgBox, Files Copied

Re: Copy Files on every USB-Drive

Posted: 19 Sep 2020, 08:59
by BoBo

Code: Select all

DriveGet, DriveList, List, REMOVABLE
drvList := StrSplit(DriveList)
For Drive in drvList {
    FileCopy, *.png,% Drive ":\"
    FileCopy, *.jpg,% Drive ":\"
}
MsgBox % "Files Copied"
Untested.

Re: Copy Files on every USB-Drive

Posted: 19 Sep 2020, 09:14
by mikeyww

Code: Select all

For driveNum, Drive in drvList {

Re: Copy Files on every USB-Drive  Topic is solved

Posted: 19 Sep 2020, 09:23
by Marius-Scripter
Found an Solution:

Code: Select all

DriveGet, DriveList, List, REMOVABLE
Loop, Parse, DriveList {
FileCopy, *.png, %A_LoopField%
FileCopy, *.jpg, %A_LoopField%
}
But thanks anyways!

Re: Copy Files on every USB-Drive

Posted: 19 Sep 2020, 09:41
by garry
your example not works for me ( drive D instead of D:\ )
maybe interesting to define source and destination folder
here an example with builtin robocopy , don't know how to define the extensions ( *.jpg / *.png )
EDIT : works with defined extensions

Code: Select all

;- Copy Files on every USB-Drive 
;- https://www.autohotkey.com/boards/viewtopic.php?f=76&t=81224

source1=%a_desktop%\TEST

DriveGet,a, List, REMOVABLE
loop,parse,A
 {
 x:=a_loopfield
 drv=%x%:\
 dest1=%drv%_BEELINK_TEST\DESKTOP\TEST
 runwait,%comspec% /k robocopy "%source1%" "%dest1%" /XO /TEE /E /UNICODE *.jpg *.png
 }
msgbox,COPY ENDED
exitapp
;=======================================================

Re: Copy Files on every USB-Drive

Posted: 19 Sep 2020, 09:42
by mikeyww

Code: Select all

DriveGet, DriveList, List, REMOVABLE
Loop, Parse, DriveList
{
 For extNum, ext in ["jpg", "png"]
  FileCopy, % "*." ext, % A_LoopField ":\"
}

Re: Copy Files on every USB-Drive

Posted: 19 Sep 2020, 09:48
by garry
@mikeyww , works fine , I'll try to add source and destination folder/subfolders

Re: Copy Files on every USB-Drive

Posted: 19 Sep 2020, 10:09
by mikeyww

Code: Select all

source = E:\data\images
target = images
overwrite := False
; --------------------------
DriveGet, DriveList, List, REMOVABLE
stitle := "Copying files (Drives: " StrLen(DriveList) ")"
SplashTextOn, 300, 100, %stitle%, Please wait....
Loop, Parse, DriveList
{
 SoundBeep, 1000, 20
 ControlSetText, Static1, % "`nDrive #" A_Index " = " A_LoopField, %stitle%
 dest = %A_LoopField%:\%target%
 If !FileExist(dest)
  FileCreateDir, %dest%
 For extNum, ext in ["jpg", "png"]
  FileCopy, % source "\*." ext, %dest%, %overwrite%
}
SplashTextOff
MsgBox, 64, Status, Done., 3
ExitApp

Re: Copy Files on every USB-Drive

Posted: 19 Sep 2020, 10:48
by garry
@mikeyww thanx, that works fine ( only not copy subfolders )

Re: Copy Files on every USB-Drive

Posted: 19 Sep 2020, 10:54
by mikeyww
Loop can recurse through subdirs. See examples.

Re: Copy Files on every USB-Drive

Posted: 19 Sep 2020, 12:40
by garry
yes, thanx