Grey Hack

Grey Hack

How to copy all files in a folder?
Hi all.
How to copy all files in a folder?
At the moment I copy each file individually.
Cheers
Oprindeligt skrevet af Xephael:
You would need to write a script for this that loops through the files in the folder.
< >
Viser 1-5 af 5 kommentarer
Forfatteren af denne tråd har angivet, at dette indlæg besvarer det oprindelige emne.
Xephael 11. juli 2021 kl. 18:53 
You would need to write a script for this that loops through the files in the folder.
Oprindeligt skrevet af Xephael:
You would need to write a script for this that loops through the files in the folder.
Many thanks, sir.
Mandrin32 7. maj 2024 kl. 11:14 
I don't understand why this script doesn't work. No file copied and no error message :

sourceDir = "/home/Mandrin/git/bin/" destinationDir = "/home/Mandrin/git/test/" computer = host_computer(get_shell) binFolder = File(computer, sourceDir) files = get_files(binFolder) for file in files copyResult = copy(file.path, destinationDir) // copyResult = copy(file.path, destinationDir, file.name) // Same result, no error but no copy if typeof(copyResult) == "string" then print("There was an error while copying file: " + copyResult) else print("File " + file.name + " got copied successfully.") end if end for

The objective is to copy 2 files (AutoWifiConnect and Publish) from "/home/Mandrin/git/bin/" to ""/home/Mandrin/git/test/" (and "/usr/bin" at the end).

When i copy the file from terminal with cp, no problem... But this script doesn't work. The copy function seems ok because the output is :
Mandrin@Mandrion:~/git/bin$ Publish File AutoWifiConnect got copied successfully. File Publish got copied successfully.

I looked for permissions but :
Mandrin@Mandrion:~/git/bin$ ls -l drwxrwxrwx Mandrin Mandrin 0 00:00 test -rwxr-xr-x Mandrin Mandrin 2850082 00:00 AutoWifiConnect -rwxr-xr-x Mandrin Mandrin 6981173 00:00 Publish
Sidst redigeret af Mandrin32; 7. maj 2024 kl. 11:17
Lordjag 7. maj 2024 kl. 13:03 
copy(path, newname)

Copies a file to a new directory path (string) with the provided name (string). Overwrites any existing file with newname.

On success, returns 1 and the terminal outputs the copied file dialogue. On failure, returns either an error (string) such as permission denied or null (if File object not valid).

usage example:
comp = get_shell.host_computer comp.File("/etc/passwd").copy(current_path, "passfile")
This example copies the /etc/passwd file to the working directory and names it 'passfile'.

I think for your code something like this:
copyResult = file.copy(destinationDir, file.name)
copyResult will be set to 1 on success
Mandrin32 8. maj 2024 kl. 2:29 
Thank you very much for your answer, it works.

I didn't see in documentation there were at least 2 "copy" functions... from File and from General

Thank you again
< >
Viser 1-5 af 5 kommentarer
Per side: 1530 50