Seeking help with script - copy file to Android device

Discuss and share scripts and script files...
Post Reply
jacksonmacd
Posts: 32
Joined: 07 Dec 2011 05:33

Seeking help with script - copy file to Android device

Post 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.

highend
Posts: 13333
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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

Post 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...
One of my scripts helped you out? Please donate via Paypal

Post Reply