I've got an raspberry pi 4, i need to copy files to any usb drive i put in my pc, now i have to manualy open 'my computer',open the usb drive letter and copy files.
Is there a way to do a copy script to a usb stick which i put in my pc?
Copy file(s) to variable usb stick station
Re: Copy file(s) to variable usb stick station
Check out DriveGet and its options.
Re: Copy file(s) to variable usb stick station
Thanx for the reply, but i am not a programmer, so i couldn't get this to work like asked earlier
Re: Copy file(s) to variable usb stick station
Can't nobody help me with this?
Re: Copy file(s) to variable usb stick station
First you have to know which letter the USB Disk using.
Then you can use FileCopy() like it is documented here https://www.autohotkey.com/docs/commands/FileCopy.htm
Then you can use FileCopy() like it is documented here https://www.autohotkey.com/docs/commands/FileCopy.htm
Re: Copy file(s) to variable usb stick station
But how can autohotkey detect which drive it suppose to write the files to?Smile_ wrote: ↑30 May 2020, 20:26First you have to know which letter the USB Disk using.
Then you can use FileCopy() like it is documented here https://www.autohotkey.com/docs/commands/FileCopy.htm
I like to put in a drive and autohotkey detects when i activate filecopy to do it's work
Re: Copy file(s) to variable usb stick station
example with filecopy or robocopy
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=76064
Detect USB drive from user 'teadrinker'
https://www.autohotkey.com/boards/viewtopic.php?t=76221&p=330409
example shows last drive , I usually copy from secondlast to lastdrive ( example D > E )
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=76064
Detect USB drive from user 'teadrinker'
https://www.autohotkey.com/boards/viewtopic.php?t=76221&p=330409
example shows last drive , I usually copy from secondlast to lastdrive ( example D > E )
Code: Select all
;-------- saved at Sonntag, 31. Mai 2020 13:07:14 --------------
;- Detect Usb Drive
;- https://www.autohotkey.com/boards/viewtopic.php?t=76221&p=330409
drivegetshow:
i=0
alldrives:=""
DriveGet, A, List,
StringSplit,D, A,
loop,%d0%
{
DRV:= % d%a_index% . ":\"
i++
DriveGet , type1 , type , %DRV% ;- removable / fixed
DriveGet , cap1 , capacity , %DRV%
DrivespaceFree , free1 , %DRV%
DriveGet , fs1 , fs , %DRV% ;- FAT
DriveGet , label1 , label , %DRV% ;- volume label >\\server1
DriveGet , serial1 , serial , %DRV% ;- volume serial number
DriveGet , status1 , status , %DRV%
alldrives .= drv . " " . type1 . " " . free1 . "-MB`n"
;msgbox, 262208,Drive-Info_%i% ,%DRV% %type1% %label1% %fs1% %cap1%-MB %free1%-MB %status1% %serial1%
lastdrive_info=%DRV% %type1% %label1% %fs1% %cap1%-MB %free1%-MB %status1% Nr=%serial1%
}
VT:=D0 ;- totaldrives
VL:=(D0-1) ;- totaldrives-1
last = %drv%
loop,%vl%
seclast := d%a_index% . ":\"
msgbox, 262208,Info ,Alldrives=`n%alldrives%`nSECLAST=%seclast%`nLAST=%last%`n----------------`nLastdrive_Info=`n%lastdrive_info%
return
;esc::exitapp
Re: Copy file(s) to variable usb stick station
Thanx i looked at it, and i can understand how this works (somewhat :p) but usb drive is variable, i've got tons of usb drives and all of them use another drive letter (at least most of them)garry wrote: ↑31 May 2020, 06:10example with filecopy or robocopy
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=76064
Detect USB drive from user 'teadrinker'
https://www.autohotkey.com/boards/viewtopic.php?t=76221&p=330409
example shows last drive , I usually copy from secondlast to lastdrive ( example D > E )Code: Select all
;-------- saved at Sonntag, 31. Mai 2020 13:07:14 -------------- ;- Detect Usb Drive ;- https://www.autohotkey.com/boards/viewtopic.php?t=76221&p=330409 drivegetshow: i=0 alldrives:="" DriveGet, A, List, StringSplit,D, A, loop,%d0% { DRV:= % d%a_index% . ":\" i++ DriveGet , type1 , type , %DRV% ;- removable / fixed DriveGet , cap1 , capacity , %DRV% DrivespaceFree , free1 , %DRV% DriveGet , fs1 , fs , %DRV% ;- FAT DriveGet , label1 , label , %DRV% ;- volume label >\\server1 DriveGet , serial1 , serial , %DRV% ;- volume serial number DriveGet , status1 , status , %DRV% alldrives .= drv . " " . type1 . " " . free1 . "-MB`n" ;msgbox, 262208,Drive-Info_%i% ,%DRV% %type1% %label1% %fs1% %cap1%-MB %free1%-MB %status1% %serial1% lastdrive_info=%DRV% %type1% %label1% %fs1% %cap1%-MB %free1%-MB %status1% Nr=%serial1% } VT:=D0 ;- totaldrives VL:=(D0-1) ;- totaldrives-1 last = %drv% loop,%vl% seclast := d%a_index% . ":\" msgbox, 262208,Info ,Alldrives=`n%alldrives%`nSECLAST=%seclast%`nLAST=%last%`n----------------`nLastdrive_Info=`n%lastdrive_info% return ;esc::exitapp
is it possible to detect the usb drive and copy 1 or more files to it from ssd -> variable usb drive
Re: Copy file(s) to variable usb stick station
example your SSD is C:\
-1-Start this script
-2-connect your USB and see LastDrive > D:\ ( or maybe X:\ )
-3-asked : "Want you COPY = C:\TEST to D:\_BEELINK_2\TEST ? (Y/N )
can you check if this works ?
Example :
SOURCE= C:\TEST
DEST =%last%_BEELINK_2\TEST
-1-Start this script
-2-connect your USB and see LastDrive > D:\ ( or maybe X:\ )
-3-asked : "Want you COPY = C:\TEST to D:\_BEELINK_2\TEST ? (Y/N )
can you check if this works ?
Example :
SOURCE= C:\TEST
DEST =%last%_BEELINK_2\TEST
Code: Select all
;- Copy file(s) to variable usb stick station
;- https://www.autohotkey.com/boards/viewtopic.php?p=332640#p332640
;- Detect Usb Drive ( from user 'teadrinker' )
;- https://www.autohotkey.com/boards/viewtopic.php?t=76221&p=330409
#warn
#NoEnv
#Singleinstance,force
Setworkingdir,%a_scriptdir%
OnMessage(0x219, "WM_DEVICECHANGE")
return
;----------------------------
EventHandler(letter, event)
{
if event
{
gosub,drivegetshow
gosub,aa
return
}
else
return
}
;----------------------------
aa:
;-----------
;source1=%a_desktop% ;
source1=C:\TEST
dest1 =%last%_BEELINK_2\TEST ;
;----------
msgbox, 262436,COPY-TEST,%alldrives%`n-------------`nLastdrive_Info=`n%lastdrive_info%`n==================`nWant you COPY =`n%source1% >>>`n%dest1% ?
IfMsgBox,No
Exitapp
runwait,%comspec% /k robocopy "%source1%" "%dest1%" /XO /E /TEE /UNICODE
msgbox, 262208, ,COPY ended`nSOURCE=%source1%`nDEST=%dest1%
exitapp
;-------------
drivegetshow:
i=0
alldrives:=""
DriveGet, A, List,
StringSplit,D, A,
loop,%d0%
{
DRV:= % d%a_index% . ":\"
i++
DriveGet , type1 , type , %DRV% ;- removable / fixed
DriveGet , cap1 , capacity , %DRV%
DrivespaceFree , free1 , %DRV%
DriveGet , fs1 , fs , %DRV% ;- FAT
DriveGet , label1 , label , %DRV% ;- volume label >\\server1
DriveGet , serial1 , serial , %DRV% ;- volume serial number
DriveGet , status1 , status , %DRV%
alldrives .= drv . " " . type1 . " " . free1 . "-MB`n"
;msgbox, 262208,Drive-Info_%i% ,%DRV% %type1% %label1% %fs1% %cap1%-MB %free1%-MB %status1% %serial1%
lastdrive_info=%DRV% %type1% %label1% %fs1% %cap1%-MB %free1%-MB %status1% Nr=%serial1%
}
VT:=D0 ;- totaldrives
VL:=(D0-1) ;- totaldrives-1
last = %drv%
loop,%vl%
seclast := d%a_index% . ":\"
;msgbox, 262208,Info ,Alldrives=`n%alldrives%`nSECLAST=%seclast%`nLAST=%last%`n----------------`nLastdrive_Info=`n%lastdrive_info%
return
;------------------------------------
;- Detect Usb Drive ( from user 'teadrinker' )
;- https://www.autohotkey.com/boards/viewtopic.php?t=76221&p=330409
/*
EventHandler(letter, event)
{
MsgBox, % "Drive " . letter . (event ? " has arrived" : " was removed")
}
*/
;------------------
WM_DEVICECHANGE(wp, lp)
{ ;- user 'teadrinker' https://www.autohotkey.com/boards/viewtopic.php?t=76221&p=330409
static DBT_DEVICEARRIVAL := 0x8000, DBT_DEVICEREMOVECOMPLETE := 0x8004, DBT_DEVTYP_VOLUME := 2
if NumGet(lp + 4, "UInt") = DBT_DEVTYP_VOLUME && (wp = DBT_DEVICEARRIVAL || wp = DBT_DEVICEREMOVECOMPLETE) {
dbcv_unitmask := NumGet(lp + 12, "UInt")
letter := Chr(Asc("A") + ln(dbcv_unitmask)/ln(2))
timer := Func("EventHandler").Bind(letter, wp = DBT_DEVICEARRIVAL)
SetTimer, % timer, -10
}
}
;=====================================
esc::exitapp
Re: Copy file(s) to variable usb stick station
Thanx Garry, I will try to explain:
Currently i am enhancing a script which download some files from my Google drive to my desktop (which in w10 is always %A_Desktop% on every w10 pc...
this script should be running on other computer too (only w10) but their last drive isnt always the usb drive, like i have: Y and Z are webdev storages so the usb drive isnt the last drive in this case...
However i will try this script and hopefully i still can use it if there is no other way
Currently i am enhancing a script which download some files from my Google drive to my desktop (which in w10 is always %A_Desktop% on every w10 pc...
this script should be running on other computer too (only w10) but their last drive isnt always the usb drive, like i have: Y and Z are webdev storages so the usb drive isnt the last drive in this case...
However i will try this script and hopefully i still can use it if there is no other way
Re: Copy file(s) to variable usb stick station
To add to this:
I've remaped the webdav drives to F and G (ssd drives are C, D and E) when this script is launched and i put the usb drive in it works perfectly, but when the webdev drives are last, the files are copied there.....
so this can help alot but i would prefer it to work only with usb drives
I've remaped the webdav drives to F and G (ssd drives are C, D and E) when this script is launched and i put the usb drive in it works perfectly, but when the webdev drives are last, the files are copied there.....
so this can help alot but i would prefer it to work only with usb drives
Re: Copy file(s) to variable usb stick station
can maybe use the drive infos , example if (serial1="12345678") or if (type1="removable") then break the loop and get drive letter ( drv )
;msgbox, 262208,Drive-Info_%i% ,%DRV% %type1% %label1% %fs1% %cap1%-MB %free1%-MB %status1% %serial1%
;msgbox, 262208,Drive-Info_%i% ,%DRV% %type1% %label1% %fs1% %cap1%-MB %free1%-MB %status1% %serial1%
Re: Copy file(s) to variable usb stick station
He seems quite hesitant to check the DriveGet command as BoBo had already suggested at the beginning of this thread?!
Besides that, it shouldn't be a problem to create a "path-pattern" that is specific for that explicit USB-Drive. So to check for that file/folder-structure shouldn't be that tough afterward.
https://autohotkey.com/board/topic/83959-run-program-based-on-usb-pid-vid-eject-and-insert-webcam/
http://www.nirsoft.net/utils/usb_devices_view.html (offers a bunch of command-line options).
Besides that, it shouldn't be a problem to create a "path-pattern" that is specific for that explicit USB-Drive. So to check for that file/folder-structure shouldn't be that tough afterward.
https://autohotkey.com/board/topic/83959-run-program-based-on-usb-pid-vid-eject-and-insert-webcam/
http://www.nirsoft.net/utils/usb_devices_view.html (offers a bunch of command-line options).
Remember to use [code]CODE[/code]-tags for your multi-line scripts. Stay safe, stay inside, and remember washing your hands for 20 sec !
Re: Copy file(s) to variable usb stick station
thanx @garry , i will try that
@BNOLI i did say i am not a programmer and so i didnt understand the script and how to use it... thats all. I wasnt disrespectfull or unthankful, i even thank him..... every effort given to help me i am thankful, always.
@BNOLI i did say i am not a programmer and so i didnt understand the script and how to use it... thats all. I wasnt disrespectfull or unthankful, i even thank him..... every effort given to help me i am thankful, always.
Re: Copy file(s) to variable usb stick station
@BNOLI thank you for the links
@loek6000 here just another short script which checks 2 serialnumbers and if it's READY and REMOVABLE asks to copy
EDIT : added more Info ( drive )
@loek6000 here just another short script which checks 2 serialnumbers and if it's READY and REMOVABLE asks to copy
EDIT : added more Info ( drive )
Code: Select all
;- Detect Usb Drive
;- https://www.autohotkey.com/boards/viewtopic.php?t=76221&p=330409
;- example with filecopy or robocopy
;- https://www.autohotkey.com/boards/viewtopic.php?f=76&t=76064
;- Detect USB drive from user 'teadrinker'
;- https://www.autohotkey.com/boards/viewtopic.php?t=76221&p=330409
;- links recommended from user BNOLI :
;- https://autohotkey.com/board/topic/83959-run-program-based-on-usb-pid-vid-eject-and-insert-webcam/
;- https://www.nirsoft.net/utils/usb_devices_view.html
#warn
#Noenv
#Singleinstance,force
;--- your USB drives ( REMOVABLE and READY ) with these serialnumbers :
u1:=2593042335
u2:=2680353722
gosub,drivegetshow
;-----------
;source1=%a_desktop%
source1=C:\TEST
dest1 =%DriveXY%_BEELINK_4\TEST
;----------
if (r=1)
gosub,aa
else
exitapp
;----------
aa:
msgbox, 262436,COPY-TEST,DRIVE FOUND with Expected Serialnumber`n%Drive_Info%`n=============`nWant you COPY =`n%source1% >>>`n%dest1% ?
IfMsgBox,No
Exitapp
runwait,%comspec% /k robocopy "%source1%" "%dest1%" /XO /E /TEE /UNICODE
msgbox, 262208, ,COPY ended`nSOURCE=%source1%`nDEST=%dest1%
exitapp
;----------------
drivegetshow:
R:=0
alldrives:=""
DriveGet, A, List,
StringSplit,D, A,
loop,%d0%
{
DRV:= % d%a_index% . ":\"
DriveGet , type1 , type , %DRV% ;- removable / fixed
DriveGet , status1 , status , %DRV%
DriveGet , serial1 , serial , %DRV% ;- volume serial number
;----------
DriveGet , cap1 , capacity , %DRV%
DrivespaceFree , free1 , %DRV%
DriveGet , fs1 , fs , %DRV% ;- FAT
DriveGet , label1 , label , %DRV% ;- volume label >\\server1
;-----------
if (type1="Removable") and (Status1="Ready")
{
if ((serial1=u1) or (serial1=u2))
{
r:=1
Drive_Info=Drive=%drv%`nType=%type1%`nStatus=%status1%`nSerial=%serial1%`nFREE=%free1%-MB`nCapacity=%cap1%-MB`nFAT_NTFS=%fs1%`nLabel=%label1%
DriveXY= %drv%
break
}
}
}
if (r=0)
{
msgbox, 262208, ,No REMOVABLE and READY drive found with expected Serialnumber
exitapp
}
return
;esc::exitapp
;=============================================
Last edited by garry on 01 Jun 2020, 05:43, edited 2 times in total.
Re: Copy file(s) to variable usb stick station
The easiest - semi-automatic - way I can think of:
- Insert your USB-drive or
- Select the file(s) you want to copy
- Right-click your selection
- From the opening context menu, select Send To > your drive
- Done
Re: Copy file(s) to variable usb stick station
Thanx all
I will work with these scripts and try how it works out
I will work with these scripts and try how it works out
Re: Copy file(s) to variable usb stick station
@Eureka , dat is juist , maar ...
script is , if you want copy without thinking ... for stupids like me ... I like this automatism and see info about drive... I copy every day the same folders to external drive ( new created or modified )
EDIT : added more info ( drive )
script is , if you want copy without thinking ... for stupids like me ... I like this automatism and see info about drive... I copy every day the same folders to external drive ( new created or modified )
EDIT : added more info ( drive )
Who is online
Users browsing this forum: No registered users and 82 guests