Page 1 of 1

Seeking help with script - copy file to Android device

Posted: 22 Jan 2024 18:57
by jacksonmacd
Trying to write a script to automate file management on an Android device. I can browse to the folder and manually copy/paste/delete/rename files. Running into problems with the script itself when I try to use variables instead of hard-coded values:

Code: Select all

$sourcefile = "E:\DroneRawFiles\output.kmz"
 $file = "40C7BC61-616C-4B5E-9840-0DD500E20E40";
 $folder = "DJI RC 2\Internal shared storage\Android\data\dji.go.v5\files\waypoint\" ;

// this works
 $fullpath = $folder . "40C7BC61-616C-4B5E-9840-0DD500E20E40" . "\";
 goto $fullpath;

// this fails
// $fullpath = $folder . "\" . $file . "\";
// goto $fullpath;   // error: path not found
// echo $fullpath;   // the output includes the literal "$file" instead of the current value
 
// this fails
 delete  $fullpath . "40C7BC61-616C-4B5E-9840-0DD500E20E40.kmz";   // error: Nothing to delete
 echo $fullpath . "40C7BC61-616C-4B5E-9840-0DD500E20E40.kmz";   // it looks correct in the message
I also tried renaming the $file variable to something else in case it was a reserved word; same errors.
How do I create the $fullpath variable by concatenating its component parts? Any help appreciated.

Re: Seeking help with script - copy file to Android device

Posted: 22 Jan 2024 19:11
by highend
Missing trailing ";":
$sourcefile = "E:\DroneRawFiles\output.kmz"

$folder has already a trailing backslash so why do you think that
$fullpath = $folder . "\" . $file . "\";
would produce a valid path (it doesn't)

Code: Select all

delete  $fullpath . "40C7BC61-616C-4B5E-9840-0DD500E20E40.kmz";   // error: Nothing to delete
Ehm, you should at least read the help file, the first argument for delete is NOT the file...