Copy Files on every USB-Drive Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Marius-Scripter
Posts: 2
Joined: 19 Sep 2020, 08:27

Copy Files on every USB-Drive

19 Sep 2020, 08:36

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
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Copy Files on every USB-Drive

19 Sep 2020, 08:59

Code: Select all

DriveGet, DriveList, List, REMOVABLE
drvList := StrSplit(DriveList)
For Drive in drvList {
    FileCopy, *.png,% Drive ":\"
    FileCopy, *.jpg,% Drive ":\"
}
MsgBox % "Files Copied"
Untested.
User avatar
mikeyww
Posts: 26880
Joined: 09 Sep 2014, 18:38

Re: Copy Files on every USB-Drive

19 Sep 2020, 09:14

Code: Select all

For driveNum, Drive in drvList {
Marius-Scripter
Posts: 2
Joined: 19 Sep 2020, 08:27

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

19 Sep 2020, 09:23

Found an Solution:

Code: Select all

DriveGet, DriveList, List, REMOVABLE
Loop, Parse, DriveList {
FileCopy, *.png, %A_LoopField%
FileCopy, *.jpg, %A_LoopField%
}
But thanks anyways!
garry
Posts: 3763
Joined: 22 Dec 2013, 12:50

Re: Copy Files on every USB-Drive

19 Sep 2020, 09:41

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
;=======================================================
Last edited by garry on 19 Sep 2020, 10:02, edited 1 time in total.
User avatar
mikeyww
Posts: 26880
Joined: 09 Sep 2014, 18:38

Re: Copy Files on every USB-Drive

19 Sep 2020, 09:42

Code: Select all

DriveGet, DriveList, List, REMOVABLE
Loop, Parse, DriveList
{
 For extNum, ext in ["jpg", "png"]
  FileCopy, % "*." ext, % A_LoopField ":\"
}
garry
Posts: 3763
Joined: 22 Dec 2013, 12:50

Re: Copy Files on every USB-Drive

19 Sep 2020, 09:48

@mikeyww , works fine , I'll try to add source and destination folder/subfolders
User avatar
mikeyww
Posts: 26880
Joined: 09 Sep 2014, 18:38

Re: Copy Files on every USB-Drive

19 Sep 2020, 10:09

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
garry
Posts: 3763
Joined: 22 Dec 2013, 12:50

Re: Copy Files on every USB-Drive

19 Sep 2020, 10:48

@mikeyww thanx, that works fine ( only not copy subfolders )
User avatar
mikeyww
Posts: 26880
Joined: 09 Sep 2014, 18:38

Re: Copy Files on every USB-Drive

19 Sep 2020, 10:54

Loop can recurse through subdirs. See examples.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, ArkuS, Nerafius, Stpham and 107 guests